8207029: Unable to use custom SSLEngine with default TrustManagerFactory after updating to JDK 11 b21

Reviewed-by: wetmore
This commit is contained in:
Xue-Lei Andrew Fan 2018-07-13 07:08:59 -07:00
parent 5bd94254bb
commit a98ec3e8bd

View file

@ -73,12 +73,20 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
boolean withDefaultCertPathConstraints) { boolean withDefaultCertPathConstraints) {
AlgorithmConstraints configuredConstraints = null; AlgorithmConstraints configuredConstraints = null;
if (socket != null) { if (socket != null) {
HandshakeContext hc = // Note that the KeyManager or TrustManager implementation may be
((SSLSocketImpl)socket).conContext.handshakeContext; // not implemented in the same provider as SSLSocket/SSLEngine.
if (hc != null) { // Please check the instance before casting to use SSLSocketImpl.
configuredConstraints = hc.sslConfig.algorithmConstraints; if (socket instanceof SSLSocketImpl) {
HandshakeContext hc =
((SSLSocketImpl)socket).conContext.handshakeContext;
if (hc != null) {
configuredConstraints = hc.sslConfig.algorithmConstraints;
} else {
configuredConstraints = null;
}
} else { } else {
configuredConstraints = null; configuredConstraints =
socket.getSSLParameters().getAlgorithmConstraints();
} }
} }
this.userSpecifiedConstraints = configuredConstraints; this.userSpecifiedConstraints = configuredConstraints;
@ -90,12 +98,20 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
boolean withDefaultCertPathConstraints) { boolean withDefaultCertPathConstraints) {
AlgorithmConstraints configuredConstraints = null; AlgorithmConstraints configuredConstraints = null;
if (engine != null) { if (engine != null) {
HandshakeContext hc = // Note that the KeyManager or TrustManager implementation may be
((SSLEngineImpl)engine).conContext.handshakeContext; // not implemented in the same provider as SSLSocket/SSLEngine.
if (hc != null) { // Please check the instance before casting to use SSLEngineImpl.
configuredConstraints = hc.sslConfig.algorithmConstraints; if (engine instanceof SSLEngineImpl) {
HandshakeContext hc =
((SSLEngineImpl)engine).conContext.handshakeContext;
if (hc != null) {
configuredConstraints = hc.sslConfig.algorithmConstraints;
} else {
configuredConstraints = null;
}
} else { } else {
configuredConstraints = null; configuredConstraints =
engine.getSSLParameters().getAlgorithmConstraints();
} }
} }
this.userSpecifiedConstraints = configuredConstraints; this.userSpecifiedConstraints = configuredConstraints;