JDBC connection on AZURE server with SSL encryption

Asked

Viewed 670 times

0

I’m having trouble connecting via JDBC in the AZURE Sqlserver database using encryption.

My connection string is as follows:

jdbc:sqlserver://servidor.database.windows.net:1433;
Database=BASE_DE_DADOS;
User=Usuario@servidor;
password=senha;
Trusted_Connection=False;
Encrypt=False;
hostNameInCertificate=*.database.windows.net;

That way it works, but if I change it to Encrypt=True;

I get the following error:

com.microsoft.sqlserver.jdbc.Sqlserverexception: Driver could not establish a secure connection to SQL Server using encryption SSL. Error: "java.security.cert.Certificateexception: Failed to validate the server name in a certificate during startup of the SSL protocol (Secure Sockets Layer)

My version of Java is 1.8.0_91

And I’m using the sqljdbc4.jar

Grateful to anyone who can help me in resolving this issue.

1 answer

1

If the Encrypt property is set to true, the trustServerCertificate property is set to false and the name of the server in the connection chain does not match the server name on SSL certificate of SQL Server, the following error will be issued: the driver failed to establish a secure connection to SQL Server using SSL protocol encryption. Error: "java.security.cert.Certificateexception: failed to validate the name of server in a certificate during SSL protocol initialization."

I believe this Link here will kill your problem. Right at the bottom of the page, there is something related to your error.

https://msdn.microsoft.com/pt-br/library/bb879949(v=sql.110). aspx

  • This link says that the server name in the connection chain does not match the server name in the SSL certificate. But another program here in the company written in C# connects that same Azure server with that connection string while the other one written in Java has this problem. I am already thinking that this message is wrong and that the problem, in fact, is another.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.