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,6 +73,10 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
boolean withDefaultCertPathConstraints) { boolean withDefaultCertPathConstraints) {
AlgorithmConstraints configuredConstraints = null; AlgorithmConstraints configuredConstraints = null;
if (socket != null) { if (socket != null) {
// Note that the KeyManager or TrustManager implementation may be
// not implemented in the same provider as SSLSocket/SSLEngine.
// Please check the instance before casting to use SSLSocketImpl.
if (socket instanceof SSLSocketImpl) {
HandshakeContext hc = HandshakeContext hc =
((SSLSocketImpl)socket).conContext.handshakeContext; ((SSLSocketImpl)socket).conContext.handshakeContext;
if (hc != null) { if (hc != null) {
@ -80,6 +84,10 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
} else { } else {
configuredConstraints = null; configuredConstraints = null;
} }
} else {
configuredConstraints =
socket.getSSLParameters().getAlgorithmConstraints();
}
} }
this.userSpecifiedConstraints = configuredConstraints; this.userSpecifiedConstraints = configuredConstraints;
this.peerSpecifiedConstraints = null; this.peerSpecifiedConstraints = null;
@ -90,6 +98,10 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
boolean withDefaultCertPathConstraints) { boolean withDefaultCertPathConstraints) {
AlgorithmConstraints configuredConstraints = null; AlgorithmConstraints configuredConstraints = null;
if (engine != null) { if (engine != null) {
// Note that the KeyManager or TrustManager implementation may be
// not implemented in the same provider as SSLSocket/SSLEngine.
// Please check the instance before casting to use SSLEngineImpl.
if (engine instanceof SSLEngineImpl) {
HandshakeContext hc = HandshakeContext hc =
((SSLEngineImpl)engine).conContext.handshakeContext; ((SSLEngineImpl)engine).conContext.handshakeContext;
if (hc != null) { if (hc != null) {
@ -97,6 +109,10 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
} else { } else {
configuredConstraints = null; configuredConstraints = null;
} }
} else {
configuredConstraints =
engine.getSSLParameters().getAlgorithmConstraints();
}
} }
this.userSpecifiedConstraints = configuredConstraints; this.userSpecifiedConstraints = configuredConstraints;
this.peerSpecifiedConstraints = null; this.peerSpecifiedConstraints = null;