I have an nginx server, which can forward request from subdomains of ropi.io. I want to secure the connection with SSL, so I generated a certificate, called ropi.pem and added it as both the ssl_certificate and ssl_certificate_key since I generated it with OpenSSL, where both the key out, and the certificate was this single file.

It works fine when browser clients want to connect to the server, but in some cases, I do need to connect with a Java client. The problem is that Java Keystore cannot import .pem files, so I - with OpenSSL again - converted it to .der format, which the Keystore accepts.

This, however, does not fix the problem, where I still cannot connect to the server from a Java client, since I get the same sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target exception.

Is there a mutual format that both Nginx, and Java Keystore can use and works for domains, CN, etc. as well?

I'm a noob, when it comes to SSL Certification, but I'm determined to learn, so please be patient with me.


I found the solution: I had to create a certificate from the key file, with the domain I want clearly stated (it'll tell where it's needed when generating).

I used the openssl req -x509 -sha256 -nodes -days 365 -key ../nginx/ropi.pem -out certificate.crt command, made sure the right files are added to the right Keystore, and I was all set

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.