N
N
Nikita Sokolov2022-02-09 13:50:23
Java
Nikita Sokolov, 2022-02-09 13:50:23

Can't connect to MSSQL via jdbc. How to fix?

I'm trying to connect logstash via jdbc to a database. On startup it gives an error:

[2022-02-09T10:41:18,391][WARN ][logstash.inputs.jdbc     ][main][795a8ca9c9762e9d9f0a4df7ec2776376174b524361e9130cd4643a5fb8d27e2] 
Exception when executing JDBC query {:exception=>Sequel::DatabaseConnectionError, :message=>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: 
The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: \"PKIX 
path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to 
requested target\". ClientConnectionId:9e4a772e-9046-457d-b812-6467d6c3fddd", :cause=>"com.microsoft.sqlserver.jdbc.SQLServerException: 
The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. 
Error: \"PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target\". ClientConnectionId:9e4a772e-9046-457d-b812-6467d6c3fddd"}


The jdbc connection itself:
input {
  jdbc {
    jdbc_driver_library => "/usr/share/logstash/mssql-jdbc-10.2.0.jre8.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://192.168.0.103;useSSL=false"
    jdbc_user => "***"
    jdbc_password => "****"
    statement => "SELECT * FROM Example"
    clean_run => true
  }
}


What are the options for a solution? How to connect without SSL? useSSL=false doesn't help. The connection to the database itself is possible - I have a JDBC connection to it right in the IDE, but logstash swears.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2022-02-09
@wb_by

Where did you get this useSSL=false from? Here is the dock from microsoft on their jdbc driver https://docs.microsoft.com/ru-ru/sql/connect/jdbc/... There are no useSSL there. For that there are encryption and trustServerCertificate There are given various options with a description. Try them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question