Troubleshooting issues with self-signed certificate

After you create a self-signed certificate and try to connect to the Oracle NoSQL Database Proxy, sometimes the connection fails.

Table 1 - Connection Failure Scenarios and Fixes

Value of CN Client Connection URL Result of the connection
CN=localhost https://localhost:8089 Connection successful
CN=proxy-nosql.example.com https://proxy-nosql.example.com:8089 Connection successful
CN=*.example.com https://proxy-nosql.example.com:8089 Connection successful
CN=proxy-nosql https://proxy-nosql:808 Connection successful
CN=proxy-nosql.example.com https://proxy-nosql:8089 Connection fails
CN=proxy-nosql.example.com https://10.0.0.9:8089 Connection fails
CN=localhost https://10.0.0.9:8089 Connection fails
CN=localhost https://proxy-nosql:8089 Connection fails
CN=localhost https://proxy-nosql.example.com:8089 Connection fails
CN=proxy-nosql https://proxy-nosql.example.com:8089 Connection fails
CN=*.example.com https://proxy-nosql.subdomain.example.com:8089 Connection fails

General Guidelines in avoiding connection failure errors:

Sample error scenarios with solution:

Example 2 - Common Name Does Not Match Short Hostname: The value of CN=proxy-nosql.example.com and the application is connecting using https://proxy-nosql:8089 and the connection fails.

The reason for connection failure is that the hostnames are not the same. You can implement one of the following solutions:

Example 3 - Wildcard Common Name Does Not Match Subdomain: The value of CN=*.example.com and the application is connecting using https://proxy-nosql.subdomain.example.com:8089 and the connection fails.

The reason for connection failure is that domain names are not the same. You can implement one of the following solutions:

Example 4 - Common Name Does Not Match Localhost: The value of CN=proxy-nosql.example.com and the application is connecting using https://localhost:8089 and the connection fails.

The reason for connection failure is that the hostnames are not the same. You can implement one of the following solutions:

Example 5 - Common Name Does Not Match IP Address: The value of CN=proxy-nosql.example.com and the application is connecting using https://10.0.0.9:8089 and the connection fails.

The reason for connection failure is that you are trying to use an IP to do the connection. You can implement one of the following solutions:

Simple commands to test if the connection would be successful :

You can use simple curl commands to simulate the connection and validate your configuration.

Use case 1: View the certificate only CN:

$ openssl x509 -text -noout -in certificate.pem | grep CN
Issuer: C=US, ST=CA, L=San,CN=proxy-nosql/emailAddress=localhost@oraclevcn.com
Subject: C=US, ST=CA, L=San, CN=proxy-nosql/emailAddress=localhost@oraclevcn.com

Fail test using curl:

$ curl --cacert certificate.pem https://node1-nosql.example.com:8087
curl: (51) Unable to communicate securely with peer: requested domain name does
not match the server's certificate.

Reason: The address in the url node1-nosql.example.com doesn’t match with CN=proxy-nosql in the certificate. And there is no SAN.

Success test using curl:

$ curl --cacert certificate.pem https://proxy-nosql:8087

Reason: The address in the url matches with CN=proxynosql in the certificate

Use case 2: Viewing the certificate CN and SAN

$ openssl x509 -text -noout -in
certificate.pem | grep CN
Issuer: CN=*.example.com
Subject: CN=*.example.com
$ openssl x509 -text -noout -in certificate.pem | grep -e DNS -e IP
  DNS:proxy-nosql,  DNS:*.subdomain.example.com, IP Address:10.0.0.9

Success test using curl:

$ curl --cacert certificate.pem https://proxy-nosql.subdomain.example.com:8087

Reason: Even if the address in the url proxy-nosql.subdomain.example.com doesn’t match with CN=*.example.com in the certificate, it matches with the SAN in the certificate subjectAltName=DNS:*.subdomain.example.com.

$ curl --cacert certificate.pem https://proxy-nosql:8087

Reason: Even if the address in the url proxy-nosql doesn’t match with CN=*.example.com in the certificate, it matches with the SAN in the certificate subjectAltName=DNS:proxy-nosql.