← Back to section · Tutorials & Labs
Inspecting the PQC Certificates and Keys in Your Hands: x509, pkey and asn1parse in Practice
Someone hands you a certificate that claims to be post-quantum — how do you confirm it really uses ML-DSA, which parameter set it is, and whether the private key matches? This article turns the inspection into concrete steps with x509, pkey and asn1parse.
Throughout a migration you will keep receiving material from other people: a certificate, a key file, a block of PEM text, all said to be signed with post-quantum algorithms. Trust cannot rest on the claim; it has to be verified item by item with tools. This article breaks the inspection into four steps: identify the algorithm, check the sizes, verify the signature, and confirm the pairing. Every command applies to classical algorithms too — with PQC material you simply swap the reference table for the FIPS parameters.
Step 1: Identify the Algorithm — Two Key Places in a Certificate
openssl x509 -in cert.pem -noout -text | less
Look for two places in the output. Signature Algorithm (it appears twice, once in the certificate body and once in the outer wrapper) states what algorithm signed this certificate; the Algorithm identifier under Subject Public Key Info states the subject’s own key type. The two can differ: an ML-DSA certificate can perfectly well be issued by an RSA CA (very common during transition), and an RSA certificate can be signed by an ML-DSA CA. The text output translates OIDs into readable names, but you should also recognise the raw OIDs, because cross-tool comparisons often show only numbers:
| Algorithm | OID |
|---|---|
| ML-KEM-512 / 768 / 1024 | 2.16.840.1.101.3.4.4.1 / .2 / .3 |
| ML-DSA-44 / 65 / 87 | 2.16.840.1.101.3.4.3.17 / .18 / .19 |
| SLH-DSA-SHA2-128s | a family starting at 2.16.840.1.101.3.4.3.20 |
If the text output shows bare numeric OIDs instead of names, it usually means your OpenSSL is too old to know these algorithms — which is itself important information: that environment cannot process such certificates and should be upgraded to 3.5 first.
Step 2: Check the Sizes — The Parameter Table Is the Hardest Evidence
Algorithm names can be mistyped or misread, but byte counts do not lie. Export the public key on its own and measure it:
openssl x509 -in cert.pem -pubkey -noout > cert-pub.pem
openssl pkey -pubin -in cert-pub.pem -outform DER | wc -c
Compare against the FIPS 204/203 public key sizes (DER encoding adds a small amount of structural overhead, so compare orders of magnitude): ML-DSA-44’s public key is 1312 bytes, ML-DSA-65’s is 1952 bytes, ML-DSA-87’s is 2592 bytes; the three ML-KEM sets are 800, 1184 and 1568 bytes. The certificate’s signature length also betrays the issuing algorithm: an ML-DSA-65 signature is 3309 bytes, and you can roughly verify it by counting the signature segment in the x509 -text output. If a certificate claims the 65 set but measures out at the 44 set’s sizes, either the material or the claim is wrong.
Step 3: Verify the Signature and the Validity Window
openssl x509 -in cert.pem -noout -dates -subject -issuer -fingerprint -sha256
openssl verify -CAfile ca.pem cert.pem
-dates shows the validity window (PQC lab certificates often carry the short default lifetimes of their issuing tools, and an expired certificate will be rejected by real validation); verify checks the whole chain and signature against the issuer’s CA certificate — for a self-signed certificate, point CAfile at the certificate itself. Note that verify’s verdict depends on whether the OpenSSL in the executing environment knows the algorithms in the certificate: versions before 3.5 will simply report ML-DSA signatures as unsupported. Exclude the tool-version factor first, then suspect the certificate.
Step 4: Pairing — Do the Private Key and Certificate Belong Together?
The most critical pre-deployment check: does the private key file in your hand pair with the certificate? A mismatched pair fails the TLS handshake directly, and the error messages rarely say why. The standard procedure is to export the public key from both sides and compare:
openssl pkey -in key.pem -pubout -out key-pub.pem
cmp key-pub.pem cert-pub.pem && echo MATCH
Comparing fingerprints of the two also works, as long as they agree. While you are at it, run openssl asn1parse -in cert.pem for a look at the overall ASN.1 structure: it lists every field and offset of the certificate line by line, and when the structure is anomalous (a damaged extensions area, non-conformant encoding) it is the fastest localisation tool available; combined with -strparse <offset> you can drill into individual fields.
Supplement: PEM vs DER, and Inspecting the Private Key File Itself
Material does not always arrive as PEM. PEM is Base64 with header and footer lines; DER is raw binary encoding. openssl x509 reads PEM by default, so a DER file needs -inform DER, and the same applies to keys (pkey -inform DER). A rough format test: a file starting with -----BEGIN is PEM; binary noise is DER. Confirming the format first in your inspection flow eliminates a whole class of mysterious “cannot read” errors.
The private key file itself is also in scope: openssl pkey -in key.pem -noout -text confirms its algorithm and parameter set (the output includes the private components, so do this only on a controlled terminal, clear the screen afterwards and mind terminal logs). More important is whether the file is passphrase-protected: if openssl pkey prompts for a passphrase when reading it, the key is stored encrypted, and an automated deployment must arrange a passphrase source — not discover at go-live that the service cannot start. One more habit worth forming: keep a fingerprint record for every certificate you receive (the -fingerprint -sha256 output from Step 3). When the other side later rotates a certificate, or you need to confirm which certificate is actually deployed in production, a fingerprint is far more reliable reconciliation evidence than a file name or a verbal description. Certificate rotation will be more frequent than usual during the PQC migration — parameter set adjustments and issuing-tool upgrades both trigger re-issuance — and a fingerprint ledger will save a migration project a great deal of mismatched-material confusion.
One more easily overlooked item: the extensions. In the X509v3 extensions in the second half of the x509 -text output, Subject Alternative Name determines which hostnames and addresses the certificate is valid for, and Key Usage / Extended Key Usage determine whether it may be used for a TLS server, code signing and so on. Certificates casually self-signed with req -x509 in PQC labs often lack a SAN or carry the wrong usages, and modern browsers and strict clients will reject them — with error messages that frequently point in unrelated directions. Read the extensions of every certificate issued during the migration: confirm the SAN covers the hostnames actually in use and that the usages match the purpose. Right algorithm, wrong extensions — the certificate still cannot go live. The command is ready-made: openssl x509 -in cert.pem -noout -ext subjectAltName shows a single extension (-ext can be repeated), and the full text comes from -text.
One real-world scenario deserves mention: hybrid and dual-certificate deployments. During transition it is common for a server to hold two sets of material — a classical certificate and a PQC certificate — presenting each according to client capability. When inspecting such a deployment, run both sets through all four steps, and additionally confirm that the server configuration has not crossed the pairings between the two certificates and their private keys — similar file names in the same directory are the classic setup for exactly that mistake. Record each set’s fingerprints as pairs in the deployment documentation and check them off by fingerprint before go-live; that is far more reliable than checking by file name.
Summary
The fixed order for inspecting PQC material: identify the algorithm with x509 -text (checking OIDs when necessary), export the public key and check its size, verify signature and validity with verify, and pair the private key with the certificate via their public keys. Keep the size table as a handy reference: public key and signature lengths are the most honest fingerprint of a parameter set, and wherever a number does not match, stop and investigate the material’s provenance instead of deploying with open questions.
Tags: OpenSSLx509certificate inspectionML-DSA