Skip to content

Unable to connect with x509v3 certificate #20

@powersjcb

Description

@powersjcb

Currently unable to connect to a mongo database using a tlsCaCert and I'm getting the following message in the logs.

2022-06-10 10:34:28,302 [348430195]   INFO - #c.i.e.r.RemoteProcessSupport - Port/ServicesPort/ID: 26991/65365/RemoteDriverImpl6de0821f
2022-06-10 10:34:28,302 [348430195]   INFO - #c.i.e.r.RemoteProcessSupport - 
2022-06-10 10:34:28,302 [348430195]   INFO - #c.i.e.r.RemoteProcessSupport - 
2022-06-10 10:34:28,337 [348430230]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Connecting to: mongodb://dbhost.com:27017/?authSource=admin&tlsAllowInvalidCertificates=true
2022-06-10 10:34:28,339 [348430232]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Auth provider: user-pass
2022-06-10 10:34:28,345 [348430238]   INFO - #c.i.d.d.DatabaseCredentialsAuthProvider - Connecting as: dbuser
2022-06-10 10:34:28,406 [348430299]   INFO - #c.i.e.r.RemoteProcessSupport - SSL MODE is REQUIRE
2022-06-10 10:34:28,406 [348430299]   INFO - #c.i.e.r.RemoteProcessSupport - setting driver log level to ALL
2022-06-10 10:34:28,406 [348430299]   INFO - #c.i.e.r.RemoteProcessSupport - setting driver log path to null
2022-06-10 10:34:28,406 [348430299]   INFO - #c.i.e.r.RemoteProcessSupport - DriverManager.LogWriter.level=ALL
2022-06-10 10:34:28,406 [348430299]   INFO - #c.i.e.r.RemoteProcessSupport - com.dbschema.level=ALL
2022-06-10 10:34:28,416 [348430309]   WARN - #c.i.e.r.RemoteProcessSupport - WARNING: password was automatically url-encoded. To turn it off set auto_encode_username_and_password driver property to false.
2022-06-10 10:34:28,449 [348430342]   WARN - #c.i.e.r.RemoteProcessSupport - Jun 10, 2022 5:34:28 PM com.mongodb.diagnostics.logging.Loggers shouldUseSLF4J
2022-06-10 10:34:28,449 [348430342]   WARN - #c.i.e.r.RemoteProcessSupport - WARNING: SLF4J not found on the classpath.  Logging is disabled for the 'org.mongodb.driver' component
2022-06-10 10:34:28,626 [348430519]   INFO - #c.i.e.r.RemoteProcessSupport - Driver: MongoDB JDBC Driver 1.13
2022-06-10 10:34:38,640 [348440533]   INFO - #c.i.e.r.RemoteProcessSupport - getDatabaseProductName: Mongo DB
2022-06-10 10:34:50,353 [348452246]   INFO - #c.i.c.ComponentStoreImpl - Saving appCodeFoldingSettings took 15 ms
2022-06-10 10:35:13,035 [348474928]   WARN - #c.i.e.r.RemoteProcessSupport - DBMS detection failed
2022-06-10 10:35:13,036 [348474929]   WARN - #c.i.e.r.RemoteProcessSupport - java.sql.SQLException: com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=dbhost.com:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: Failed to parse server certificates}, caused by {java.security.cert.CertificateParsingException: no more data allowed for version 1 certificate}}]
2022-06-10 10:35:13,036 [348474929]   WARN - #c.i.e.r.RemoteProcessSupport - at com.dbschema.mongo.mongosh.MongoshScriptEngine.execute(MongoshScriptEngine.java:74)
2022-06-10 10:35:13,036 [348474929]   WARN - #c.i.e.r.RemoteProcessSupport - at com.dbschema.mongo.MongoPreparedStatement.executeQuery(MongoPreparedStatement.java:55)
2022-06-10 10:35:13,036 [348474929]   WARN - #c.i.e.r.RemoteProcessSupport - at com.dbschema.mongo.MongoPreparedStatement.execute(MongoPreparedStatement.java:61)
2022-06-10 10:35:13,036 [348474929]   WARN - #c.i.e.r.RemoteProcessSupport - at com.dbschema.mongo.MongoPreparedStatement.execute(MongoPreparedStatement.java:479)

I have confirmed my credentials and tlsCaCert work using the mongosh and mongodb-compass clients.

$ mongo \
  ...
		--ssl \
		--sslCAFile x509v3file.crt \
		--sslAllowInvalidHostnames \
		--sslAllowInvalidCertificates \
		...
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: ...
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: ...
        Validity
            Not Before: Oct 14 21:59:48 2016 GMT
            Not After : Oct 12 21:59:48 2026 GMT
        ...
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    ...
                Exponent: ...
        X509v3 extensions:
            X509v3 Subject Key Identifier:
                ...
            X509v3 Authority Key Identifier:
                ...
            X509v3 Basic Constraints:
                CA:TRUE
    Signature Algorithm: sha256WithRSAEncryption

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions