“The CN on the certificate is correct, but the browser shows a name error.”
“I handed over the .crt file, but they say the product can’t load it.”
Both are problems you can solve quickly once you can read the contents of a certificate. The former is almost always a problem with the SAN, and the latter with the file format.
In Part 3, we created self-signed certificates with openssl and PowerShell. In Part 4, we read the contents (X.509) of such a certificate. We will cover what each field means, which extensions to look at, and how to tell file formats apart.
- The structure of a certificate
- Basic fields
- How to write the subject (DN)
- SAN: host names are verified only against the SAN
- How to write a SAN and its matching rules
- Key extensions, part 1: purpose and constraints
- Key extensions, part 2: identifiers, locations, policies, and CT
- File formats and extensions
- Converting formats
- Reading the contents, part 1: openssl
- Reading the contents, part 2: Windows (PowerShell and certutil)
- Fetching a certificate from a server
- Think about it
- Summary
- The Certificate Fundamentals series (11 parts)
The structure of a certificate
The certificate format is defined by ITU-T’s X.509, and RFC 5280 specifies how it is used on the internet. The version in use today is version 3 (v3).

A certificate consists of three parts.
- tbsCertificate (to be signed): everything the certificate claims, including the issuer, the subject (the owner), the validity period, the public key, and the extensions
- Signature algorithm
- Signature value: the result of the certificate authority (CA), the issuer, signing the tbsCertificate with its own private key
The verifier checks the signature value with the issuer’s public key and confirms that the content has not been rewritten and that the CA really did issue it (the same mechanism as the signatures in Part 2).
In other words, a certificate is a document in which a CA signs the statement “the owner of this public key is this name.” The signature covers all of ①, so the CA vouches for the name, the period, and the extensions. Changing even one bit makes signature verification fail.
Basic fields
| Field | Shown by openssl as | Meaning | Example |
|---|---|---|---|
| Version | Version | Only v3 can have extensions. Almost all certificates today are v3 | 3 (0x2) |
| Serial number | Serial Number | A number unique per issuer. Revocation also points to a certificate by this number | 61:ae:ba:e2:… (up to 20 bytes) |
| Signature algorithm | Signature Algorithm | The method the CA used to sign | ecdsa-with-SHA256, sha256WithRSAEncryption |
| Issuer | Issuer | The name (DN) of the CA that signed | CN=Example Issuing CA E1 |
| Validity period | Validity (Not Before / Not After) | Valid only within this period. Recorded in UTC | Sep 26 2026 to Apr 13 2027 GMT |
| Subject | Subject | The name (DN) of the owner | CN=www.example.com |
| Subject public key | Subject Public Key Info | The public key and its algorithm | EC P-256, RSA 2048-bit |
| Extensions | X509v3 extensions | Names (SAN), purposes, whether it is a CA, and so on | Subject Alternative Name, etc. |
- The serial number of a public CA’s certificate must include at least 64 bits of random data so that it cannot be guessed (the Baseline Requirements, Part 5)
- The validity period is recorded in UTC. openssl shows it in GMT, while the Windows screen and PowerShell show local time (in Japan, 9 hours ahead). When you report an expiration date, say which time you mean
How UTC, GMT, and JST relate, and how an OS keeps time in UTC and converts it to local time for display, is explained in Part 2 of the series NTP Fundamentals.
How to write the subject (DN)
The subject and issuer are written in a format called a DN (distinguished name).
| Abbreviation | Attribute | Meaning | Example |
|---|---|---|---|
| C | countryName | Country (ISO 3166 two-letter code) | JP |
| ST | stateOrProvinceName | State or prefecture | Tokyo |
| L | localityName | City or ward | Chiyoda-ku |
| O | organizationName | Organization name. Verified for OV and EV | Example Corp. |
| OU | organizationalUnitName | Department name. Cannot be included in public CA certificates since September 1, 2022 | (not included) |
| CN | commonName | By convention, an FQDN. Not used for host name verification | www.example.com |
The same certificate looks different depending on the tool.
openssl display: C=JP, ST=Tokyo, L=Chiyoda-ku, O=Example Corp., CN=www.example.com
Windows display: CN=www.example.com, O=Example Corp., L=Chiyoda-ku, S=Tokyo, C=JP
In openssl’s -subj and configuration files, you write ST= (RFC 4514). The Windows screen and PowerShell, however, show the same attribute as S=, and the order is reversed (CN first). Also, the subject of a DV certificate is often just CN=, without C, ST, L, or O.
SAN: host names are verified only against the SAN
Here is the answer to “the CN is correct but there is a name error” from the beginning.
The SAN (Subject Alternative Name) is an extension that lists the host names and IP addresses the certificate can be used for. The only thing a browser compares with the name you are accessing is the SAN. It does not look at the CN.

The fallback of using the CN when there is no SAN was removed by Chrome in Chrome 58 in 2017, and RFC 9525 in 2023 explicitly states that the CN must not be used for identification. Public CA certificates have been required to include a SAN since 2012.
Even if you write the correct name in the CN, if it is not in the SAN you get NET::ERR_CERT_COMMON_NAME_INVALID.
On the other hand, some tools, such as openssl’s -verify_hostname, still look at the CN when there is no SAN. If “it passes in openssl but gives an error in the browser,” suspect that the SAN was left out.
Key points
• Names are matched only against the SAN. Neither browsers nor RFC 9525 use the CN
• Write the name in the SAN even if there is only one. If you include a CN, make it the same as the SAN value
• Some tools look at the CN, so a check can pass in a tool and still fail in a browser
How to write a SAN and its matching rules
Let’s sort out which names a value written in the SAN matches.

Wildcards, in particular, are often misunderstood.
*.example.commatcheswww.example.comandmail.example.com- But it does not match
example.comitself. If you need it, also listDNS:example.com - It does not match two levels down, such as
a.b.example.com, either. A wildcard replaces only the leftmost label (RFC 9525)
If you check with openssl, a name two levels down produces an error.
$ openssl x509 -in wc.crt -noout -ext subjectAltName
X509v3 Subject Alternative Name:
DNS:*.example.com, DNS:example.com, IP Address:192.0.2.10
$ openssl verify -CAfile root.crt -untrusted inter.crt -verify_hostname a.b.example.com wc.crt
CN=*.example.com
error 62 at 0 depth lookup: hostname mismatch
error wc.crt: verification failed
For a management console opened by IP address, write it with the IP: type. If it is also opened by host name, list DNS: as well (IP: alone does not match a connection by host name). Few public CAs issue IP address certificates; Let’s Encrypt has offered them since January 2026 as short-lived certificates with a validity of about 6 days. How to decide the SAN values and when to use wildcards is covered in Part 6.
Key extensions, part 1: purpose and constraints
| Extension | Meaning | In a server certificate | In a CA certificate |
|---|---|---|---|
| Basic Constraints | Whether it is a CA (CA:TRUE/FALSE) and how many levels can sit below it (pathlen) | CA:FALSE (critical) | CA:TRUE. Intermediate CAs often have pathlen:0 |
| Key Usage | Operations the key may be used for | Digital Signature (Key Encipherment may also be included for RSA) | Certificate Sign, CRL Sign |
| Extended Key Usage (EKU) | The purpose of the certificate | TLS Web Server Authentication (serverAuth) | For an intermediate CA, limits the purposes it may issue for |
| Name Constraints | The range of names it may issue for | Not included | For example, limiting a private CA to names under corp.example.com |
- A verifier that does not understand an extension marked critical must reject the certificate (RFC 5280)
- The Chrome Root Program is moving public CA hierarchies to server authentication only, so for server certificates issued on or after March 15, 2027, the EKU is limited to serverAuth only. For client certificates (mTLS, Part 7), use a private CA (Part 9)
Key extensions, part 2: identifiers, locations, policies, and CT
| Extension | Meaning | How it is used |
|---|---|---|
| Subject Key Identifier (SKI) | An identifier for its own public key | Required in CA certificates. A clue for building the chain |
| Authority Key Identifier (AKI) | An identifier for the issuer’s public key | Matched against the parent’s SKI. Distinguishes CAs even when several share the same name |
| Authority Information Access (AIA) | The URL of the issuer’s certificate (CA Issuers) and the OCSP URL | Automatic retrieval of intermediate certificates, revocation checks (Part 5) |
| CRL Distribution Points (CDP) | The URL of the certificate revocation list (CRL) | Revocation checks (Part 5) |
| Certificate Policies | OIDs indicating the issuance policy | 2.23.140.1.2.1 = DV, 2.23.140.1.2.2 = OV, 2.23.140.1.1 = EV |
| CT Precertificate SCTs | Proof of registration in CT logs (SCTs) | Chrome, Safari, and Firefox reject public certificates with too few SCTs (Part 5) |
If you read a Let’s Encrypt certificate now, the AIA has only CA Issuers, and there is no OCSP URL. This is because OCSP was ended in 2025 and the CDP is included instead (Part 5).
If you can recognize these six and the four in the previous table, that is enough to read certificates in practice.
File formats and extensions
This is the “I handed over the .crt but it can’t be loaded” story.

| Format | Content | How to recognize it | Main uses |
|---|---|---|---|
| PEM | DER encoded as a Base64 string (RFC 7468) | Starts with —–BEGIN CERTIFICATE—– | Apache, nginx, Linux in general. Several certificates can be concatenated |
| DER | The ASN.1 structure written directly as binary | Starts with 30 82 in hex. Garbled when opened as text | Java, Windows .cer (when it is DER) |
| PKCS#12 (.pfx/.p12) | Certificate + chain + private key in one file, encrypted with a password | Binary. Asks for a password when opened | Windows (IIS), Azure, Java keystores |
| PKCS#7 (.p7b) | Only the certificate and chain. No private key | —–BEGIN PKCS7—– or binary | Distributing intermediate certificates, importing a chain into Windows |
An extension does not guarantee the content. .crt and .cer may be PEM or DER, and a .pem file may contain a private key. Judge by the word after BEGIN on the first line (CERTIFICATE, PRIVATE KEY, PKCS7, and so on). Show the first line with head -1, or Get-Content -TotalCount 1 in PowerShell.
Converting formats
$ openssl x509 -in server.crt -outform DER -out server.der # PEM → DER
$ openssl x509 -in server.der -inform DER -out server.pem # DER → PEM
$ openssl pkcs12 -export -inkey server.key -in server.crt \
-certfile inter.crt -out server.pfx # → PKCS#12
$ openssl pkcs12 -in server.pfx -noenc -out all.pem # PKCS#12 → PEM
$ openssl crl2pkcs7 -nocrl -certfile fullchain.pem -out chain.p7b # → PKCS#7
PS> certutil -encode server.der server.pem # DER → PEM (-decode for the reverse)
PS> Export-PfxCertificate -Cert Cert:\LocalMachine\My\<thumbprint> -FilePath server.pfx `
-Password (Read-Host -AsSecureString) # store → PKCS#12
These three points often cause trouble when converting.
- To check whether a certificate and a private key are a pair, see whether the values from
openssl x509 -in server.crt -noout -pubkey | openssl sha256andopenssl pkey -in server.key -pubout | openssl sha256match - PKCS#12 files from OpenSSL 3 are encrypted with AES-256. Windows Server 2016 and earlier cannot import them and report “the password is incorrect,” so recreate the file with
-legacy - Windows’ built-in features cannot create a .pfx from a PEM private key. Either create the CSR on Windows (
certreq, Part 6) or use PowerShell 7’s[X509Certificate2]::CreateFromPemFile()
Reading the contents, part 1: openssl
$ openssl x509 -in server.crt -noout -text
Serial Number:
61:ae:ba:e2:5c:18:e5:03:b7:d2:6a:d8:87:49:26:83:dd:3c:00:e5
Signature Algorithm: ecdsa-with-SHA256
Issuer: C=JP, O=Example CA Inc., CN=Example Issuing CA E1
Not Before: Sep 26 00:55:58 2026 GMT
Not After : Apr 13 00:55:58 2027 GMT
Subject: C=JP, ST=Tokyo, L=Chiyoda-ku, O=Example Corp., CN=www.example.com
Public-Key: (256 bit)
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Extended Key Usage:
TLS Web Server Authentication
X509v3 Subject Alternative Name:
DNS:www.example.com, DNS:example.com
(The output is an excerpt of the main parts only.)
Read it in this order.
- SAN and Subject (whose certificate it is)
- Issuer (who issued it)
- Not After (until when, in GMT)
- Basic Constraints and EKU (what it can be used for)
If the Issuer and Subject are the same, it is self-signed (a root certificate, or one you made yourself).
If you only need the essentials, use openssl x509 -in server.crt -noout -subject -issuer -dates -ext subjectAltName. Adding -checkend 2592000 returns exit code 1 if the certificate expires within 30 days, so you can use it for monitoring (Part 8).
Reading the contents, part 2: Windows (PowerShell and certutil)
PS> $c = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new("C:\work\server.crt")
PS> $c | Format-List Subject, Issuer, NotBefore, NotAfter, Thumbprint
Subject : CN=www.example.com, O=Example Corp., L=Chiyoda-ku, S=Tokyo, C=JP
Issuer : CN=Example Issuing CA E1, O=Example CA Inc., C=JP
NotBefore : 2026/09/26 9:55:58
NotAfter : 2027/04/13 9:55:58
Thumbprint : 1B2958866A114AC0EA9D7000EF51F137DBDA0614
PS> $c.Extensions | ForEach-Object { $_.Oid.FriendlyName; $_.Format($false) }
PS> Get-ChildItem Cert:\LocalMachine\My | Format-List Subject, DnsNameList, NotAfter, Thumbprint
PS> certutil -dump server.crt
X509Certificate2works in both Windows PowerShell 5.1 and PowerShell 7. Times are in local time (JST), so they look 9 hours ahead of openssl’s GMT- You can turn an extension into text with
Format()onExtensions. The labels follow the display language of Windows. On a Japanese-language Windows, the SAN is shown as 「サブジェクト代替名」 and the EKU as 「拡張キー使用法」. The SAN value itself is shown asDNS Name=www.example.com, DNS Name=example.comin both languages - Certificates installed on a server can be listed through the
Cert:\drive, andDnsNameListshows the DNS names in the SAN.certutil -dumpshows all fields, similar to openssl’s-text - The thumbprint is a SHA-1 fingerprint of the whole certificate, a value used to point to a certificate. It has nothing to do with the signature algorithm, and SHA-1 is fine here
Fetching a certificate from a server
Finally, here is how to fetch a certificate from a running server.
$ openssl s_client -connect www.example.com:443 -servername www.example.com -showcerts </dev/null
Certificate chain
0 s:C=JP, ST=Tokyo, L=Chiyoda-ku, O=Example Corp., CN=www.example.com
i:C=JP, O=Example CA Inc., CN=Example Issuing CA E1
v:NotBefore: Sep 26 00:55:58 2026 GMT; NotAfter: Apr 13 00:55:58 2027 GMT
1 s:C=JP, O=Example CA Inc., CN=Example Issuing CA E1
i:C=JP, O=Example CA Inc., CN=Example Root CA R1
Verify return code: 0 (ok)

- No. 0 is the server certificate, and No. 1 and later are the intermediate certificates the server sent. If the i: (issuer) of each number equals the s: (subject) of the next, they are linked
- Without
-servername(SNI, Part 7), you may get the certificate of a different site - If the intermediate certificate is not sent, you get
Verify return code: 21 (unable to verify the first certificate)(Parts 5 and 10)
On Windows, you can fetch it with PowerShell like this.
PS> $tcp = [System.Net.Sockets.TcpClient]::new("www.example.com", 443)
PS> $ssl = [System.Net.Security.SslStream]::new($tcp.GetStream(), $false, { $true })
PS> $ssl.AuthenticateAsClient("www.example.com")
PS> $c = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new($ssl.RemoteCertificate)
PS> $c | Format-List Subject, Issuer, NotAfter
PS> [IO.File]::WriteAllBytes("C:\work\www.cer", $c.Export("Cert")); $ssl.Dispose(); $tcp.Dispose()
{ $true } is a setting that receives the certificate without validating it. Use it only for the purpose of examining the contents. You can read the saved .cer with the methods in the previous sections.
Think about it
- Pick one server certificate used in your organization and read it with
openssl x509 -textorcertutil -dump. Does the SAN contain every name users actually type (short names, aliases, and IP addresses)? - Someone says, “I handed over the certificate file (.crt), but the product can’t load it.” What could be the cause? What do you check first?
- Might a homegrown monitoring script or an old device be checking the host name against the CN instead of the SAN? How would you find out?
Hint: Look at “SAN: host names are verified only against the SAN,” “File formats and extensions” (the first line of the file), and “Converting formats” (checking that a key and certificate are a pair).
Summary
- A certificate is a document in which a CA signs a pair of a public key and a name. The signature covers the whole thing, including the name, the period, and the extensions
- Host names are verified only against the SAN. Even if you write the name in the CN, it is an error if it is not in the SAN
- A wildcard covers only the leftmost label. It includes neither the domain itself nor names two levels down
- The extensions to look at are about ten, including Basic Constraints, Key Usage, EKU, AIA, and CDP
- An extension does not guarantee the content. Tell the format from the first line
- Report an expiration date with whether it is in UTC (GMT) or local time
Next time, we cover PKI and how trust works: how far back up the chain of issuers a certificate is trusted.
The Certificate Fundamentals series (11 parts)
All 11 parts with a reading guide: Certificate Fundamentals
- Why Do We Need Certificates?
- Cryptography basics
- Trying it with openssl and PowerShell
- Inside an X.509 certificate (this article)
- PKI and how trust works
- Certificate types and issuance
- How TLS works
- Lifecycle and automation
- Private PKI and the cloud
- Certificate troubleshooting
- Certificate design exercises
This series is the English edition of 【証明書入門】, originally written in Japanese.


コメント