-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handshake_failure(40); nested exception is org.bouncycastle.tls.TlsFatalAlert: handshake_failure(40) #1156
Comments
We need more information to help you. What version of BC jars are you using? Do you have a full stack trace for the exception? What system are you trying to make a TLS connection to? |
@peterdettman Peter I am sharing all the detail, please help. Thanks I am setting these Java options export _JAVA_OPTIONS="-Djdk.tls.trustNameService=true -Dorg.bouncycastle.jca.enable_jks=true -Djava.security.debug=provider -Djava.security.properties==/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/jre/lib/security/java.security.bcfips -Dorg.bouncycastle.fips.approved_only=true" Changing these properties in JAVA.security file security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider These are my jar versions. bc-fips-1.0.2.1.jar We are trying to connect to audit-publish service https://cobalt-gke.gk.cobalt.only.sap/auditpublish-dev/greeting This is full stack trace Mon Apr 25 01:32:25.273 GMT 2022 [parallel-1] [o.b.jsse.provider.ProvTlsClient: INFO ] - Client raised fatal(2) handshake_failure(40) alert: Failed to read record |
@peterdettman Peter I am sharing all the detail, please help. Thanks I am setting these Java options export _JAVA_OPTIONS="-Djdk.tls.trustNameService=true -Dorg.bouncycastle.jca.enable_jks=true -Djava.security.debug=provider -Djava.security.properties==/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/jre/lib/security/java.security.bcfips -Dorg.bouncycastle.fips.approved_only=true" Changing these properties in JAVA.security file security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider These are my jar versions. bc-fips-1.0.2.1.jar We are trying to connect to audit-publish service https://cobalt-gke.gk.cobalt.only.sap/auditpublish-dev/greeting This is full stack trace Mon Apr 25 01:32:25.273 GMT 2022 [parallel-1] [o.b.jsse.provider.ProvTlsClient: INFO ] - Client raised fatal(2) handshake_failure(40) alert: Failed to read record |
This exception happens when the server simply closes the connection before the handshake has completed. It means that you would need to look at the server logs in order to know the reason for the failure. If the server logs aren't accessible, you could get a packet capture of the connection attempt using e.g. Wireshark and we might be able to see something obvious. It might also be worth trying with the latest available FIPS jars (at least we can rule out already-fixed bugs): bc-fips-1.0.2.3.jar |
@peterdettman Peter
I had this code which was creating issue, When i changed this Code to this it worked,
} When I am using HttpClient to make Https call it works and when it uses HttpsUrlConnection it throws me handshake failure, Is it the expected behaviour of HttpsUrlConnection with BCFIPS? Please provide your thoughts on it. |
The two code examples look the same to me. Do you mean that you changed the URL from http to https? HTTP doesn't use TLS at all, so it doesn't have much to do with this issue. The question is why the TLS connection fails and from what I can see the error happens at the server. Do you know of any other client software that is able to make an HTTPS connection to this same server? |
@peterdettman Sorry Peter i updated the above answer, two codes are now different, Can you check now. |
The HTTP connection doesn't use TLS, and the HTTPS connection does use TLS, but gets the handshake_failure exception. The TLS connection happens (and fails) before any request is sent, so the error has nothing to do with the application traffic (HTTP). Do you have other software that can connect to the HTTPS URL? |
My current service makes an outbound TLS connection to AuditPublish service to check the status of this service using this url https://cobalt-gke.gk.cobalt.only.sap/auditpublish-dev/greeting". For which I am getting Handshake failure. This is the code for the Https call.
|
I think im seeing this exact same issue. My keycloak has an auditlog .jar deployed which makes HTTPS requests. We have 2 requests happening -- one to our AuthZ server to get an access token, another to actually POST to auditlog (behind apigateway). The call to AuthZ goes through perfectly (not hosted on AWS infra), but when we try to hit auditlog, we see handshake_failed(40) with no other informative errors. Seems like this handshake_failed is due to client/server not agreeing on terms of connection. I have forced TLSv1.2, so im sure keycloak is using it for the AuthZ call and the Auditlog call. |
I ran into similar issue and setting : ssl.KeyManagerFactory.algorithm=PKIX in the java.security file worked for me. Seems like BCFIPS doesn't support SunX509. |
@amitlpande You say "similar issue". Can you please confirm whether or not you had the exact same stack trace, namely org.bouncycastle.tls.TlsFatalAlert: handshake_failure(40)
at org.bouncycastle.tls.TlsProtocol.safeReadRecord(TlsProtocol.java:846)
at org.bouncycastle.tls.TlsProtocol.blockForHandshake(TlsProtocol.java:416)
at org.bouncycastle.tls.TlsClientProtocol.connect(TlsClientProtocol.java:86) (perhaps with some slightly different line numbers)? |
Health Check: service at URL https://cobalt-gke/auditpublish-dev/greeting responded with message I/O error on GET request for "https://cobalt-gke/auditpublish-dev/greeting": handshake_failure(40); nested exception is org.bouncycastle.tls.TlsFatalAlert: handshake_failure(40)
The text was updated successfully, but these errors were encountered: