JDBC connection to the AZURE server with SSL encryption

0

I'm having trouble connecting via JDBC to AZURE's 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 to Encrypt=True;

I get the following error:

  

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

My version of Java is 1.8.0_91

And I'm using sqljdbc4.jar

Thank you to anyone who can assist me in resolving this issue.

    
asked by anonymous 01.07.2016 / 20:50

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 string does not match the server name in the   SQL Server SSL certificate, the following error will be issued: the driver   failed to establish a secure connection to SQL Server using   SSL encryption. Error:   "java.security.cert.CertificateException: Failed to validate the name of the   server on 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 about your error.

link

    
02.07.2016 / 19:24