# JDBC input with SSL enabled

**URL:** <https://discuss.elastic.co/t/jdbc-input-with-ssl-enabled/233516>\
**Category:** Logstash\
**Created:** [May 20, 2020, 11:14am UTC](https://discuss.elastic.co/t/jdbc-input-with-ssl-enabled/233516 "2020-05-20T11:14:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chandu5565](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@chandu5565](https://discuss.elastic.co/u/chandu5565)\
**Post date:** [May 20, 2020, 11:14am UTC](https://discuss.elastic.co/t/jdbc-input-with-ssl-enabled/233516/1 "2020-05-20T11:14:42Z")

</div>

Hi,

Earlier I was using logstash jdbc plugin to input mongodb data which was working fine. Now we have made changes to our mongodb and enabled SSL , replicaset with self signed certificate.

I am not sure how can I give my CA information in JDBC input or connection string.

Earlier configuration which was working without ssl is

```auto
input {
jdbc {
jdbc_driver_library =>""
jdbc_driver_class => "com.dbschema.MongoJdbcDriver"
jdbc_connection_string => "jdbc:mongodb://username:password@IP:PORT/db_name?authSource=admin"
jdbc_user => ""
jdbc_validate_connection => true
schedule => "* * * * * * UTC"
statement => "db.getCollection('Dbname').find({})"
   }
}

```

my new connection string looks like this

```auto
mongodb://username:password@IP1:PORT1,IP2:PORT2,IP3:PORT3/db_name?authSource=admin&replicaSet=mongodb-replica&ssl=true&sslAllowInvalidCertificates=true

```

help is really appreciated.

Thanks,  
chandra kanth

---

<div class="post-metadata">

**Author:** ![chandu5565](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@chandu5565](https://discuss.elastic.co/u/chandu5565)\
**Post date:** [May 21, 2020, 9:59am UTC](https://discuss.elastic.co/t/jdbc-input-with-ssl-enabled/233516/2 "2020-05-21T09:59:52Z")

</div>

I resolve this by adding Certificate authority file to keystore. Below are steps that I did.

1. By changing the mongo-java-driver-3.6.4.jar to mongo-java-driver-3.12.0.jar
2. By changing mongojdbc1.2.jar to mongojdbc1.7.jar.
3. copying ca.pem file to path /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/
4. adding ca.pem to keystore with below command.  
keytool -keystore cacerts -storepass enterkeystorepassword -noprompt -trustcacerts -importcert -alias testdbcert -file ca.pem
5. changing the connection string in logstash input to

```auto
 mongodb://username:password@IP1:PORT1,IP2:PORT2,IP3:PORT3/db_name?authSource=admin&replicaSet=mongodb-replica&ssl=true&sslInvalidHostNameAllowed=true

```

Hope this will be helpful to someone else.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 18, 2020, 9:59am UTC](https://discuss.elastic.co/t/jdbc-input-with-ssl-enabled/233516/3 "2020-06-18T09:59:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
