1

After creating a new S/MIME certificate, I am stuck with creating a valid PKCS #12 file that is accepted by most mail clients:

$ openssl verify smime.pfx
CN = [email protected], emailAddress = [email protected]
error 20 at 0 depth lookup: unable to get local issuer certificate
error smime.pfx: verification failed

If I specify the intermediate certificate, the chain looks fine:

openssl verify -show_chain -untrusted Certum_SMIME_RSA_CA.pem smime.pfx
smime.pfx: OK
Chain:
depth=0: CN = [email protected], emailAddress = [email protected] (untrusted)
depth=1: C = PL, O = Asseco Data Systems S.A., CN = Certum SMIME RSA CA (untrusted)
depth=2: C = PL, O = Asseco Data Systems S.A., OU = Certum Certification Authority, CN = Certum Trusted Root CA

However, that file has been specified when creating the pfx file:

$ openssl pkcs12 -export -inkey privatekey.key -in smime.pem \
    -certfile Certum_SMIME_RSA_CA.pem -out smime.pfx

According to openssl, the intermediate certificate is present:

$ openssl pkcs12 -in smime.pfx -nodes | grep -E "subject|issuer"
subject=CN = [email protected], emailAddress = [email protected]
issuer=C = PL, O = Asseco Data Systems S.A., CN = Certum SMIME RSA CA
subject=C = PL, O = Asseco Data Systems S.A., CN = Certum SMIME RSA CA
issuer=C = PL, O = Asseco Data Systems S.A., OU = Certum Certification Authority, CN = Certum Trusted Root CA

So what exactly am I missing here? Why is the intermediate certificate that is part of of the pfx file ignored?

1 Answer 1

1

From the man page:

openssl verify [options skipped] [–] [certificate ...]

[option descriptions skipped]

certificate ...

    One or more target certificates to verify, one per file. If no certificates are given, this 
    command will attempt to read a single certificate from standard input.

Note "one per file". Certs needed to build the chain for that one cert will be looked for in -untrusted and -trusted if specified, and in -CAfile/path/store if specified or else their respective defaults if the related -no option is not specified -- but not in the input file.

Using a PKCS12-aka-PFX file for input to verify is only supported in 3.0.0 up (since 2021), but the equivalent error of trying to verify a PEM-format 'chain' file has been common for a long time; see https://stackoverflow.com/questions/65204616/why-does-openssl-verify-fail-with-a-certificate-chain-file-while-it-succeeds-wit and more linked there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .