Self-Signed certificate: openssl 21 (unable to verify the first certificate)

118 Views Asked by At

I have created a self-signed certificate in azure.

The certificate is installed on an ubuntu machine. Process:

sudo -s
cp <cert> /usr/share/ca-certificates
dpkg-reconfigure ca-certificates

dpkg-reconfigure shows gui.

enter image description here

I select yes to trust the certificate. On the next page, I see a list of certificates. I select my certificate (by pressing space key) and press ok (tab -> enter)

The certificate is added successfully.

But when I run openssl s_client -showcerts -connect <server>:<port>, I get Verify return code: 21 (unable to verify the first certificate)

I have tested this localhost (mac OS X). It works after I set Always Trust for When using this certificate under Trust section of the certificate. (Certificate locally is created directly using openssl commands)

openssl req  -new  -newkey rsa:2048  -nodes  -keyout localhost.key  -out localhost.csr
openssl  x509  -req  -days 365  -in localhost.csr  -signkey localhost.key  -out localhost.crt

I'm running a Golang server where this certificate is used with the key vai http.ListenAndServeTLS function.

The process on mac is really simply. Just drag and drop the certificate in the Keychain Access and trust the certificate.

This is a major blocker for me. I would really appreciate the help.

0

There are 0 best solutions below