ProvSSLSessionHandshake getLocalSupportedSignatureAlgorithms throws UnsupportedOperationException
It appears that when trying to use the tls provider and the tls version is >= 1.2 the X509TrustManager attempts to call getLocalSupportedSignatureAlgorithms() on the ExtendedSSLSession which is expected to return an empty array (https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/ExtendedSSLSession.html#getPeerSupportedSignatureAlgorithms--)
At a glance, it appears that the issue is due to ProvSSLSessionHandshake throwing an UnsupportedOperationException
org.bouncycastle.jsse.provider.ProvTlsClient notifyAlertRaised
WARNING: Client raised fatal(2) internal_error(80) alert: Failed to read record
java.lang.UnsupportedOperationException
at org.bouncycastle.jsse.provider.ProvSSLSessionHandshake.getLocalSupportedSignatureAlgorithms(Unknown Source)
at org.bouncycastle.jsse.provider.ExportSSLSession_7.getLocalSupportedSignatureAlgorithms(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:212)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at org.bouncycastle.jsse.provider.ImportX509TrustManager_7.checkServerTrusted(Unknown Source)
at org.bouncycastle.jsse.provider.ProvSSLSocketDirect.checkServerTrusted(Unknown Source)
at org.bouncycastle.jsse.provider.ProvTlsClient$1.notifyServerCertificate(Unknown Source)
at org.bouncycastle.tls.TlsUtils.processServerCertificate(Unknown Source)
at org.bouncycastle.tls.TlsClientProtocol.handleServerCertificate(Unknown Source)
at org.bouncycastle.tls.TlsClientProtocol.handleHandshakeMessage(Unknown Source)
at org.bouncycastle.tls.TlsProtocol.processHandshakeQueue(Unknown Source)
at org.bouncycastle.tls.TlsProtocol.processRecord(Unknown Source)
at org.bouncycastle.tls.RecordStream.readRecord(Unknown Source)
at org.bouncycastle.tls.TlsProtocol.safeReadRecord(Unknown Source)
at org.bouncycastle.tls.TlsProtocol.blockForHandshake(Unknown Source)
at org.bouncycastle.tls.TlsClientProtocol.connect(Unknown Source)
at org.bouncycastle.jsse.provider.ProvSSLSocketDirect.startHandshake(Unknown Source)
at org.bouncycastle.jsse.provider.ProvSSLSocketDirect.startHandshake(Unknown Source)
at pps.common.framework.web.SSLContextBuilder$DelegateSSLSocket.startHandshake(SSLContextBuilder.java:444)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
BCJSSE provides its own TrustManagerFactory and KeyManagerFactory and doesn't currently interoperate with the SunJSSE ones (although it can work on older JDKs or earlier TLS versions).
Therefore, either explicitly specify the BCJSSE provider for your TMF (and KMF) - use the "PKIX" algorithm for both, or else install the BCJSSE provider with higher priority than the SunJSSE provider.
You will probably also want to set the default KMF/TMF algorithms to "PKIX" in java.security: ssl.KeyManagerFactory.algorithm=PKIX ssl.TrustManagerFactory.algorithm=PKIX
Hi peter,thank you very much. I modified the code according to your comments and it worked