Skip to content

Commit 8d0f385

Browse files
committed
8279520: SPNEGO has not passed channel binding info into the underlying mechanism
Reviewed-by: mullan, valeriep
1 parent b3dbfc6 commit 8d0f385

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

src/java.security.jgss/share/classes/sun/security/jgss/spnego/SpNegoContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -866,6 +866,7 @@ private byte[] GSS_initSecContext(byte[] token) throws GSSException {
866866
mechContext.requestMutualAuth(mutualAuthState);
867867
mechContext.requestReplayDet(replayDetState);
868868
mechContext.requestSequenceDet(sequenceDetState);
869+
mechContext.setChannelBinding(channelBinding);
869870
if (mechContext instanceof GSSContextImpl) {
870871
((GSSContextImpl)mechContext).requestDelegPolicy(
871872
delegPolicyState);
@@ -899,6 +900,7 @@ private byte[] GSS_acceptSecContext(byte[] token) throws GSSException {
899900
myCred.getInternalCred());
900901
}
901902
mechContext = factory.manager.createContext(cred);
903+
mechContext.setChannelBinding(channelBinding);
902904
}
903905

904906
// pass token to mechanism acceptSecContext

test/jdk/sun/security/krb5/auto/IgnoreChannelBinding.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 6851973 8194486
26+
* @bug 6851973 8194486 8279520
2727
* @summary ignore incoming channel binding if acceptor does not set one
2828
* @library /test/lib
2929
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
@@ -33,6 +33,7 @@
3333
import java.net.InetAddress;
3434
import org.ietf.jgss.ChannelBinding;
3535
import org.ietf.jgss.GSSException;
36+
import org.ietf.jgss.Oid;
3637
import sun.security.jgss.GSSUtil;
3738

3839
public class IgnoreChannelBinding {
@@ -41,33 +42,38 @@ public static void main(String[] args)
4142
throws Exception {
4243

4344
new OneKDC(null).writeJAASConf();
45+
test(GSSUtil.GSS_KRB5_MECH_OID);
46+
test(GSSUtil.GSS_SPNEGO_MECH_OID);
47+
}
48+
49+
static void test(Oid mech) throws Exception {
4450

4551
Context c = Context.fromJAAS("client");
4652
Context s = Context.fromJAAS("server");
4753

4854
// All silent
49-
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
50-
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
55+
c.startAsClient(OneKDC.SERVER, mech);
56+
s.startAsServer(mech);
5157
Context.handshake(c, s);
5258

5359
// Initiator req, acceptor ignore
54-
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
60+
c.startAsClient(OneKDC.SERVER, mech);
5561
c.x().setChannelBinding(new ChannelBinding(
5662
InetAddress.getByName("client.rabbit.hole"),
5763
InetAddress.getByName("host.rabbit.hole"),
5864
new byte[0]
5965
));
60-
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
66+
s.startAsServer(mech);
6167
Context.handshake(c, s);
6268

6369
// Both req, and match
64-
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
70+
c.startAsClient(OneKDC.SERVER, mech);
6571
c.x().setChannelBinding(new ChannelBinding(
6672
InetAddress.getByName("client.rabbit.hole"),
6773
InetAddress.getByName("host.rabbit.hole"),
6874
new byte[0]
6975
));
70-
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
76+
s.startAsServer(mech);
7177
s.x().setChannelBinding(new ChannelBinding(
7278
InetAddress.getByName("client.rabbit.hole"),
7379
InetAddress.getByName("host.rabbit.hole"),
@@ -76,13 +82,13 @@ public static void main(String[] args)
7682
Context.handshake(c, s);
7783

7884
// Both req, NOT match
79-
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
85+
c.startAsClient(OneKDC.SERVER, mech);
8086
c.x().setChannelBinding(new ChannelBinding(
8187
InetAddress.getByName("client.rabbit.hole"),
8288
InetAddress.getByName("host.rabbit.hole"),
8389
new byte[0]
8490
));
85-
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
91+
s.startAsServer(mech);
8692
s.x().setChannelBinding(new ChannelBinding(
8793
InetAddress.getByName("client.rabbit.hole"),
8894
InetAddress.getByName("host.rabbit.hole"),
@@ -96,8 +102,8 @@ public static void main(String[] args)
96102
}
97103

98104
// Acceptor req, reject
99-
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
100-
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
105+
c.startAsClient(OneKDC.SERVER, mech);
106+
s.startAsServer(mech);
101107
s.x().setChannelBinding(new ChannelBinding(
102108
InetAddress.getByName("client.rabbit.hole"),
103109
InetAddress.getByName("host.rabbit.hole"),

0 commit comments

Comments
 (0)