java , "SSLHonorCipherOrder".
, Sun Sun JSSE (bootclasspath), Server
.
: sun.security.ssl.ServerHandshaker
public static boolean preferServerOrder = true;
selectCipherSuite:
private void chooseCipherSuite(final HandshakeMessage.ClientHello mesg) throws IOException {
if(preferServerOrder) {
final CipherSuiteList clientList = mesg.getCipherSuites();
for(final CipherSuite serverSuite : getActiveCipherSuites().collection()) {
if (this.doClientAuth == 2) {
if (serverSuite.keyExchange == CipherSuite.KeyExchange.K_DH_ANON) continue;
if (serverSuite.keyExchange == CipherSuite.KeyExchange.K_ECDH_ANON) continue;
}
if(!serverSuite.isNegotiable()) continue;
if(clientList.contains(serverSuite)) {
if (trySetCipherSuite(serverSuite)) return;
}
}
} else {
final Collection list = mesg.getCipherSuites().collection();
for(final CipherSuite suite : list) {
if (!(isNegotiable(suite))) continue;
if (this.doClientAuth == 2) {
if (suite.keyExchange == CipherSuite.KeyExchange.K_DH_ANON) continue;
if (suite.keyExchange == CipherSuite.KeyExchange.K_ECDH_ANON) continue;
}
if (trySetCipherSuite(suite)) return;
}
}
fatalSE(Alerts.alert_handshake_failure, "no cipher suites in common");
}
source
share