LinuxCommandLibrary

openssl-x509

multi-purpose certificate utility

TLDR

View certificate details

$ openssl x509 -in [certificate.crt] -text -noout
copy
Get certificate fingerprint
$ openssl x509 -in [certificate.crt] -fingerprint -sha256 -noout
copy
Convert PEM to DER
$ openssl x509 -in [cert.pem] -outform DER -out [cert.der]
copy
Check expiration date
$ openssl x509 -in [certificate.crt] -enddate -noout
copy
Extract public key
$ openssl x509 -in [certificate.crt] -pubkey -noout
copy
Create self-signed from key
$ openssl x509 -req -in [csr.pem] -signkey [key.pem] -out [cert.pem] -days [365]
copy

SYNOPSIS

openssl x509 [options] [-in file] [-out file]

DESCRIPTION

openssl x509 is a multi-purpose certificate utility. It can display information, convert formats, sign certificates, and modify certificate properties.
One of the most commonly used OpenSSL commands for certificate management.

PARAMETERS

-in file

Input certificate.
-out file
Output file.
-text
Print text form.
-noout
Don't output certificate.
-fingerprint
Print fingerprint.
-subject, -issuer
Print subject/issuer.
-dates
Print validity dates.
-pubkey
Output public key.
-req
Input is CSR.
-signkey file
Self-sign with key.

COMMON QUERIES

$ # Subject
openssl x509 -in cert.pem -subject -noout

# Validity dates
openssl x509 -in cert.pem -dates -noout

# Serial number
openssl x509 -in cert.pem -serial -noout
copy

CAVEATS

Different from openssl req which creates certificates. Use -noout with info commands to suppress PEM output.

HISTORY

X.509 is the ITU-T standard for PKI, with OpenSSL providing comprehensive tooling since its early versions.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community