简体   繁体   English

JDBC连接问题Java证书异常

[英]JDBC Connection Issue Java Certificate Exception

I was able to use the JDBC driver that came with DataGrip (I'm using a Mac) and seeing the following error message, it was working perfectly fine before and I didn't disturb anything: 我能够使用DataGrip随附的JDBC驱动程序(我使用的是Mac),并看到以下错误消息,之前它运行得非常好,并且我没有打扰任何事情:

Connection to SQL Azure failed
Driver cannot establish (SSL) connection SQL Server
Error: "java.security.cert.CertificateException: cannot authenticat 
(SSL)  ClientConnectionId:d66ab....

I have tried updating the SQL JDBC driver but still can not see the database content. 我尝试更新SQL JDBC驱动程序,但仍然看不到数据库内容。 Any ideas ? 有任何想法吗 ?

EDIT: This is the stack trace I was able to find: 编辑:这是我能够找到的堆栈跟踪:

This is the stack trace I was able to find:[08S01] Driver unable to use SSL to establish secure connection with SQL Server。Error: "java.security.cert.CertificateException: can not verify the name of the server in the security communication layer (SSL) initialization period。"。 ClientConnectionId:b7c55361-d82f-4bc1-b1be-124d18433c3b java.security.cert.CertificateException: can not verify the name of the server in the security communication layer (SSL) initialization period 这是我能够找到的堆栈跟踪:[08S01]驱动程序无法使用SSL与SQL Server建立安全连接。错误:“ java.security.cert.CertificateException:无法在安全通信中验证服务器的名称ClientConnectionId:b7c55361-d82f-4bc1-b1be-124d18433c3b java.security.cert.CertificateException:无法在安全通信层(SSL)初始化期间验证服务器的名称。

atcom.microsoft.sqlserver.jdbc.TDSChannel$HostNameOverrideX509TrustManager.validateServerNameInCertificate(IOBuffer.java:1491) at com.microsoft.sqlserver.jdbc.TDSChannel$HostNameOverrideX509TrustManager.checkServerTrusted(IOBuffer.java:1384) at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:922) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1488) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1688) atcom.microsoft.sqlserver.jdbc.TDSChannel $ HostNameOverrideX509TrustManager.checkServerTrusted(IOBuffer.java:1384)上的atcom.microsoft.sqlserver.jdbc.TDSChannel $ HostNameOverrideX509TrustManager.validateServerNameInCertificate(IOBuffer.java:1491)在sun.security.ssl.AbstractTrust位于sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1488)处的checkServerTrusted(SSLContextImpl.java:922)位于sun.security.ssl.Handshaker处的sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)处的证书sun.security.ssl上的.processLoop(Handshaker.java:979).sun.security.ssl上的Handshaker.process_record(Handshaker.java:914).sun.security.ssl上的SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)。 com.microsoft.sqlserver上的sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)上的SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)在com.microsoft.sqlserver上的sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) .jdbc.TDSChannel.enableSSL(IOBuffer.java:1688) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1977) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168) at com.intellij.database.remote.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.ru 在com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1977)在com.microsoft.sqlserver.jdbc.SQLServerServer.login(SQLServerConnection.java:1628)在com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal (SQLServerConnection.java:1459)在com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773)在com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168)在com.intellij。在sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在sun.reflect。 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)上的java.lang.reflect.Method.invoke(Method.java:497)上的DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) .transport $ 1.run(Transport.java:200)位于sun.rmi.transport.Transport $ 1.ru n(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$256(TCPTransport.java:683) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) n(Transport.java:197),位于java.security.AccessController.doPrivileged(本机方法),位于sun.rmi.transport.Transport.serviceCall(Transport.java:196),位于sun.rmi.transport.tcp.TCPTransport.handleMessages(位于sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.run0(TCPTransport.java:826)的TCPTransport.java:568)位于sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.lambda $ run $ 256(TCPTransport.java:683)的TCPTransport.java:826) ),位于java.security.AccessController.doPrivileged(本机方法),位于sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.run(TCPTransport.java:682),位于java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) )在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)在java.lang.Thread.run(Thread.java:745)

Thanks all for your help. 感谢你的帮助。 I've investigated and found that the issue could be related to the fact I upgraded to OS Sierra and then DataGrip seemed to break. 我进行了调查,发现问题可能与我升级到OS Sierra然后DataGrip似乎坏了有关。 The solution that I found was the following: 我发现的解决方案如下:

If the hostname of the connecting client is not set or ends with .local, the connection will fail. 如果未设置连接客户端的主机名或以.local结尾,则连接将失败。 After I set the hostname, then it was working again. 设置主机名后,它又可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM