Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing RDS With SSL - Unsupported record version Unknown-0.0

Tags:

ssl

rds

I am using Amazon RDS MySQL and connecting with SSL certificate(the default certificate available at http://s3.amazonaws.com/rds-downloads/mysql-ssl-ca-cert.pem), I am doing the following steps:

  1. Downloaded the mysql-ssl-ca-cert.pem
  2. Modified the above file to JKS format
  3. And connecting from a web application through Spring - Hibernate template (org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) and also use c3p0, we are setting additional URL parameter as jdbc:URL/DB?autoReconnect=true&useUniCode=true&characterEncoding=UTF-8&useSSL=true&verifyServerCertificate=false&requireSSL=true

But I am facing the below issue...

javax.net.ssl.SSLException: Unsupported record version Unknown-0.0

How can I fix this?

like image 556
R.G.Karthic Balaji Avatar asked Nov 20 '12 11:11

R.G.Karthic Balaji


2 Answers

Basically it means that the SSL parser is lost. The sockets layer has passed it some bytes that don't fit the SSL protocol.

When you transmit using an SSL Socket, it calls a formatting and encryption routine to create the encrypted packet. It then calls the plain sockets layer to transfer the encrypted packet to the server. The server's sockets layer receives the packet and then calls the SSL package to decrypt the packet. If the packet doesn't fit the SSL format, you get the unsupport version exception.

All bytes that arrive at the socket layer are sent to the SSL package. So the simplest way to get that error is to use the plain sockets layer to transmit a plain text message after establishing the SSL connection.

In my particular case, I ran into this error message because I was transmitting extra bytes. Let's see if I can explain my mistake clearly.

I had a buffer that was (for example) 100 bytes. I packed the buffer with my 50 byte message and called the SSL encryption routine. The resulting packet was 75 bytes long. I called send() to transmit the buffer. This was a plain sockets send; it did what I told it to do, which was transmit the entire 100 byte buffer.

At the server, the entire 100 bytes was received. The SSL package tried to decrypt the packet. It found a perfectly good SSL message packed into the first 75 bytes that were received. So far so good. Then it tried to figure out what the remaining 25 bytes meant. It assued that it was a SECOND SSL message and tried to decrypt it. That's when it choked and kicked out that nasty exception.

I hope that gives you some clues about what to look for in your code.

like image 54
user1965077 Avatar answered Sep 26 '22 00:09

user1965077


I found this error if I presented an unsupported client certificate. Blanking out "-Djavax.net.ssl.keyStore" and connecting with no client certificate worked.

See also http://feed.askmaclean.com/archives/secure-java-connections-by-default.html :

Support for various TLS versions differs based on the JRE version used. Make sure you know the capabilities of the JDK you are using before restricting specific TLS versions. When first running the test above, Eclipse was using JRE 1.6.0_45 instead of JRE 1.8.0_65 I expected, and was connecting using TLSv1.0 ciphers. When MySQL Server was configured to only allow TLSv1.1 and TLSv1.2, I received the following Exception:

Caused by: javax.net.ssl.SSLException: Unsupported record version Unknown-0.0 at com.sun.net.ssl.internal.ssl.InputRecord.readV3Record(InputRecord.java:504)

Usage of older JREs should be assessed before disabling TLSv1.0 – fortunately, PERFORMANCE_SCHEMA makes it easy to survey client JREs without having to inspect every application server.

like image 43
Rich Avatar answered Sep 26 '22 00:09

Rich