1
$\begingroup$

I'm going to verify the CA certificate from Yubico. I copied the whole certificate from

-----BEGIN CERTIFICATE----- to -----END CERTIFICATE----- in a file with the ending .pem. Then I wanted to verify this with openssl verify test.pem in the command line (test.pem is my file with the certificate). I got

test.pem: CN = Yubico U2F Root CA Serial 457200631
error 18 at 0 depth lookup:self signed certificate
OK

I'm very new to openssl and openSUSE, so I don't know how I can solve this problem. My aim is to verify a certificate against this CA file. But first I want to get this error off.

$\endgroup$
  • $\begingroup$ It says it's been signed with pgp so maybe use that? $\endgroup$ – Henno Brandsma Dec 2 '15 at 20:10
  • $\begingroup$ I'm sorry, but I don't know what I have to do (with pgp) now. Would you like to explain it? $\endgroup$ – BElanna Torres Dec 2 '15 at 22:31
3
$\begingroup$

Well, they say they use gpg to sign the file (yubico-utf-ca-certs.txt) and the signature is in the linked file. So

gpg --verify yubico-u2f-ca-certs.txt.sig yubico-u2f-ca-certs.txt  

gpg: Signature made Tue Sep  2 11:18:24 2014 CEST using RSA key ID 32F8119D
gpg: requesting key 32F8119D from hkp server keys.gnupg.net
gpg: key 54265E8C: public key "Simon Josefsson <simon@josefsson.org>" imported
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2019-08-28
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
gpg: Good signature from "Simon Josefsson <simon@josefsson.org>"
gpg:                 aka "Simon Josefsson <simon@yubico.com>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 9AA9 BDB1 1BB1 B99A 2128  5A33 0664 A769 5426 5E8C
     Subkey fingerprint: 9941 5CE1 905D 0E55 A9F8  8026 860B 7FBB 32F8 119D

Ok. This shows that the file in question was signed (validly) by someone at Yubico, so it seems.

The cert itself (some_cert.pem) is self-signed so openssl has to be told to trust it: "verify" checks the chain of certificates but here the chain ends right away: the cert signs itself. In this case you want to check the signature (but this says nothing about the origin of the cert, anyone can make a self-signed cert with Yubico in the name!), so we can do

openssl verify -trusted some_cert.pem -check_ss_sig some_cert.pem

Which indeed says OK (it says to check the last (here only) link, the self-signed one, and to explicitly trust the signer; normally there is a directory of trusted certs that openssl knows about or needs to be told about in a command line argument.).

To inspect the cert (that you now trust the origin of, due to it being signed by gpg etc.) and checked the signature of, e.g. do

openssl x509 -in some_cert.pem -noout -text

which outputs all the fields including the serial, which was also in the signed text file. So now you see that all is consistent in itself. But you have to believe the gpg key (from a key server) and the fact that the file is hosted on the site etc. The gpg key is untrusted according to my gpg install...

Hope this helps.

$\endgroup$
  • $\begingroup$ Thank you very much! It solved my problem ;) In addition I understand the error now! $\endgroup$ – BElanna Torres Dec 4 '15 at 11:25
  • $\begingroup$ Glad to be able to help! $\endgroup$ – Henno Brandsma Dec 4 '15 at 11:30
  • $\begingroup$ I couldn't find the option -trusted in the man pages or online. Where does it come from? $\endgroup$ – Javier Jul 22 '17 at 19:41
  • $\begingroup$ @Rodrigo Me neither at this point. Replace it with -CAfile some_cert.pem and it should work. $\endgroup$ – Henno Brandsma Jul 22 '17 at 19:48

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.