OPENSSL-X509(1SSL)
๐ openssl-x509 (1SSL) ๐
okay bestie, this is openssl-x509 from the 1SSL manual โ cert display and signing, but make it make sense. ๐
โจ NAME โจ
openssl-x509โ Certificate display and signing command. ๐
โจ SYNOPSIS โจ
openssl x509 [-help] [-in filename|uri] [-passin arg] [-new]
[-x509toreq] [-req] [-copy_extensions arg] [-inform DER|PEM] [-vfyopt
nm:v] [-key filename|uri] [-keyform DER|PEM|P12] [-signkey filename|uri]
[-out filename] [-outform DER|PEM] [-nocert] [-noout] [-dateopt] [-text]
[-certopt option] [-fingerprint] [-alias] [-serial] [-startdate]
[-enddate] [-dates] [-subject] [-issuer] [-nameopt option] [-email]
[-hash] [-subject_hash] [-subject_hash_old] [-issuer_hash]
[-issuer_hash_old] [-ext extensions] [-ocspid] [-ocsp_uri] [-purpose]
[-pubkey] [-modulus] [-multi] [-checkend num] [-checkhost host]
[-checkemail host] [-checkip ipaddr] [-set_serial n] [-next_serial]
[-not_before date] [-not_after date] [-days arg] [-preserve_dates]
[-set_issuer arg] [-set_subject arg] [-subj arg] [-force_pubkey
filename] [-clrext] [-extfile filename] [-extensions section] [-sigopt
nm:v] [-badsig] [-digest] [-CA filename|uri] [-CAform DER|PEM|P12]
[-CAkey filename|uri] [-CAkeyform DER|PEM|P12] [-CAserial filename]
[-CAcreateserial] [-trustout] [-setalias arg] [-clrtrust] [-addtrust
arg] [-clrreject] [-addreject arg] [-rand files] [-writerand file]
[-provider name] [-provider-path path] [-provparam [name:]key=value]
[-propquery propq]
โจ DESCRIPTION โจ
This command is a multi-purpose certificate-handling queen. She can print certificate information, convert certificates to various forms, edit certificate trust settings, generate certificates from scratch or from certification requests, and then self-sign them or sign them like a "micro CA". ๐
Generated certificates bear X.509 version 3. Unless specified otherwise, key identifier extensions are included as described in x509v3_config(5). โจ
Since there are a large number of options, they will split up into various sections. No cap.
๐ OPTIONS ๐
๐ ๏ธ Input, Output, and General Purpose Options ๐ ๏ธ
-helpโ Print out a usage message. Because a little reminder never hurt nobody. ๐ซถ-in filename|uriโ This specifies the input to read a certificate from, or the input file for reading a certificate request if the-reqflag is used. In both cases this defaults to standard input. ๐ซ This option cannot be combined with the-newflag.-passin argโ The key and certificate file password source. For more information about the format ofarg, seeopenssl-passphrase-options(1). ๐-newโ Generate a certificate from scratch, not using an input certificate or certificate request. So this excludes the-inand-reqoptions. Instead, the-set_subjectoption needs to be given. The public key to include can be given with the-force_pubkeyoption and defaults to the key given with the-key(or-signkey) option, which implies self-signature. โจ-x509toreqโ Output a PKCS#10 certificate request (rather than a certificate). The-key(or-signkey) option must be used to provide the private key for self-signing; the corresponding public key is placed in thesubjectPKInfofield. ๐ X.509 extensions included in a certificate input are not copied by default. X.509 extensions to be added can be specified using the-extfileoption.-reqโ By default a certificate is expected on input. With this option a PKCS#10 certificate request is expected instead, which must be correctly self-signed. ๐ X.509 extensions included in the request are not copied by default. X.509 extensions to be added can be specified using the-extfileoption.-copy_extensions argโ Determines how to handle X.509 extensions when converting from a certificate to a request using the-x509toreqoption, or converting from a request to a certificate using the-reqoption. Ifargisnoneor this option is not present, then extensions are ignored. Ifargiscopyorcopyall, then all extensions are copied, except that subject identifier and authority key identifier extensions are not taken over when producing a certificate request. ๐ The-extoption can be used to further restrict which extensions to copy.-inform DER|PEMโ The input file format to use; by defaultPEMis tried first. Seeopenssl-format-options(1)for details. ๐ฅ-vfyopt nm:vโ Pass options to the signature algorithm during verify operations. Names and values of these options are algorithm-specific. ๐งช-key filename|uriโ This option provides the private key for signing a new certificate or certificate request. Unless-force_pubkeyis given, the corresponding public key is placed in the new certificate or certificate request, resulting in a self-signature. ๐ This option cannot be used in conjunction with the-CAoption. It sets the issuer name to the subject name (i.e., makes it self-issued). Unless the-preserve_datesoption is supplied, it sets the validity start date to the current time and the end date to a value determined by the-daysoption. Start date and end date can also be explicitly supplied with options-not_beforeand-not_after.-signkey filename|uriโ This option is an alias of-key. ๐ช-keyform DER|PEM|P12โ The key input format; unspecified by default. Seeopenssl-format-options(1)for details. ๐๏ธ-out filenameโ This specifies the output filename to write to, or standard output by default. ๐ค-outform DER|PEMโ The output format; the default isPEM. Seeopenssl-format-options(1)for details. ๐ฆ-nocertโ Do not output a certificate (except for printing as requested by below options). ๐ โโ๏ธ-nooutโ This option prevents output except for printing as requested by below options. ๐คซ
๐จ๏ธ Certificate Printing Options ๐จ๏ธ
Note: the-aliasand-purposeoptions are also printing options, but they are described in the "Trust Settings" section.
-dateoptโ Specify the date output format. Values are:rfc_822andiso_8601. Defaults torfc_822. ๐-textโ Prints out the certificate in text form. Full details are printed, including the public key, signature algorithms, issuer and subject names, serial number, any extensions present, and any trust settings. ๐-certopt optionโ Customise the print format used with-text. Theoptionargument can be a single option or multiple options separated by commas. The-certoptswitch may also be used more than once to set multiple options. See the "Text Printing Flags" section for more information. ๐จ-fingerprintโ Calculates and prints the digest of the DER encoded version of the entire certificate (see digest options). This is commonly called a"fingerprint". Because of the nature of message digests, the fingerprint of a certificate is unique to that certificate, and two certificates with the same fingerprint can be considered to be the same. ๐-aliasโ Prints the certificate"alias"(nickname), if any. ๐ท๏ธ-serialโ Prints the certificate serial number. ๐ข-startdateโ Prints out the start date of the certificate, that is thenotBeforedate. ๐ข-enddateโ Prints out the expiry date of the certificate, that is thenotAfterdate. ๐ด-datesโ Prints out the start and expiry dates of a certificate. ๐๏ธ-subjectโ Prints the subject name. ๐ค-issuerโ Prints the issuer name. ๐๏ธ-nameopt optionโ This specifies how the subject or issuer names are displayed. Seeopenssl-namedisplay-options(1)for details. ๐ช-emailโ Prints the email address(es), if any. ๐ง-hashโ Synonym for-subject_hashfor backward compatibility reasons. ๐ฐ๏ธ-subject_hashโ Prints the"hash"of the certificate subject name. This is used in OpenSSL to form an index to allow certificates in a directory to be looked up by subject name. ๐-subject_hash_oldโ Prints the"hash"of the certificate subject name using the older algorithm as used by OpenSSL before version 1.0.0. ๐ฆ-issuer_hashโ Prints the"hash"of the certificate issuer name. ๐งพ-issuer_hash_oldโ Prints the"hash"of the certificate issuer name using the older algorithm as used by OpenSSL before version 1.0.0. ๐ฆ-ext extensionsโ Prints out the certificate extensions in text form. Can also be used to restrict which extensions to copy. Extensions are specified with a comma separated string, e.g.,"subjectAltName, subjectKeyIdentifier". See thex509v3_config(5)manual page for the extension names. ๐งฉ-ocspidโ Prints the OCSP hash values for the subject name and public key. ๐ชช-ocsp_uriโ Prints the OCSP responder address(es), if any. ๐-purposeโ This option performs tests on the certificate extensions and outputs the results. For a more complete description, see"Certificate Extensions"inopenssl-verification-options(1). ๐ฏ-pubkeyโ Prints the certificate'sSubjectPublicKeyInfoblock in PEM format. ๐-modulusโ This option prints out the value of the modulus of the public key contained in the certificate. ๐งฎ-multiโ This option prints selected information about all certificates contained in the input. ๐งบ
๐ Certificate Checking Options ๐
-checkend argโ Without-multi, checks if the certificate expires within the nextargseconds and exits nonzero if it will expire, or zero if not. โณ With-multi, checks if any certificate in the input will expire within the nextargseconds and exits nonzero if any will expire, or zero if none will.-checkhost hostโ Check that the certificate matches the specified host. ๐-checkemail emailโ Check that the certificate matches the specified email address. ๐ฌ-checkip ipaddrโ Check that the certificate matches the specified IP address. ๐
๐ Certificate Output Options ๐
-set_serial nโ Specifies the serial number to use. This option can be used with the-key,-signkey, or-CAoptions. If used in conjunction with the-CAoption, the serial number file (as specified by the-CAserialoption) is not used. ๐ซ The serial number can be decimal or hex (if preceded by"0x").-next_serialโ Set the serial to be one more than the number in the certificate. โ-not_before dateโ This allows the start date to be explicitly set. The format of the date isYYMMDDHHMMSSZ(the same as an ASN1UTCTimestructure), orYYYYMMDDHHMMSSZ(the same as an ASN1GeneralizedTimestructure). In both formats, secondsSSand timezoneZmust be present. Alternatively, you can also use"today". ๐๏ธ Cannot be used together with the-preserve_datesoption.-not_after dateโ okay so this one lets you straight up hardcode when the cert dies. The date format isYYMMDDHHMMSSZ(same vibe as an ASN1UTCTimestructure), orYYYYMMDDHHMMSSZ(same as an ASN1GeneralizedTimestructure). In both formats, the secondsSSand the timezoneZmust be there, no skipping. You can also just write"today"if that's the energy you're on.
Not compatible with -preserve_dates, bestie, pick a lane. And heads up: this one overrides the -days option entirely.
-days argโ how many days from today until a freshly generated certificate says goodbye. Default is30.
Cannot be used together with -preserve_dates. And if -not_after is set, that explicit expiry date wins, periodt.
-preserve_datesโ when signing a certificate, keep thenotBeforeandnotAfterdates of any input certificate instead of glamming them up to current time and duration. Cannot be used together with-days,-not_beforeand-not_after.-set_issuer argโ when a certificate is created, set its issuer name to the given value.
Peep -set_subject for how the arg has to be formatted.
-set_subject argโ when a certificate is created, set its subject name to the given value. When the cert is self-signed, the issuer name gets set to the same value too, unless you passed the-set_issueroption.
The arg must be formatted as "/type0=value0/type1=value1/type2=...". Special characters can be escaped with "\" (backslash), and whitespace is retained, no cap. Empty values are allowed, but then that type won't show up in the certificate at all. Giving a single "/" gets you an empty sequence of RDNs (a NULL-DN). Multi-valued RDNs? Form them by putting a "+" character instead of a "/" between the AttributeValueAssertions (AVAs) that specify the members of the set. Example:
"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe"
This option can be used with -new and -force_pubkey to create a whole new certificate without providing an input certificate or certificate request. Iconic behaviour, honestly.
-subj argโ this option is an alias of-set_subject. Same girl, different name ๐-force_pubkey filenameโ when a new certificate or certificate request is created, set its public key to the given key instead of the key contained in the input or given with the-key(or-signkey) option. If the input contains no public key but does contain a private key, its public part gets used.
This one can vibe with -new and -set_subject to directly generate a certificate containing literally any public key you want.
Also super useful for creating self-issued certificates that are not self-signed โ for instance when the key can't be used for signing, like with DH.
-clrextโ when transforming a certificate into a new certificate, all certificate extensions are retained by default.
But when transforming a certificate or certificate request, -clrext stops any extensions from being taken over from the source. In any case, when producing a certificate request, neither the subject identifier nor the authority key identifier extensions are included.
-extfile filenameโ configuration file containing certificate and request X.509 extensions to add.
When both -extfile filename and -extensions section options are given, the extensions to add come from the named section of the file named filename. That file must exist, be readable, and all the listed extensions must be valid.
If only the -extfile filename option is given, the section name to use comes from the value of the variable named "extensions" in the file's unnamed section (also called its default section, see config(5)). If no extensions setting is found, the file's default (unnamed) section itself is used instead as the list of extensions to add. As before, the file must be readable and all the extensions must be valid.
Prior to OpenSSL 4.0, the -extensions option required that the -extfile option be also specified. As of OpenSSL 4.0 the default configuration file is used instead, as described below.
If only the -extensions section option is given, the named section of the default configuration file โ whether from the "OPENSSL_CONF" environment variable, or the built-in default โ is used as the list of extensions to add. As before, the file must be readable and all the extensions must be valid.
If neither option is given, an attempt is made to open the default configuration file (as detailed above). If the file doesn't exist or can't be opened, no extensions are added. If the unnamed section (default, see config(5)) of the file doesn't list an extensions variable, no extensions are added. Otherwise, the section named by the extensions variable is taken to be the list of extensions to add. The extensions listed there must all be valid.
-extensions sectionโ the section in the extfile to add X.509 extensions from. See the description of-extfileabove for the deets.
And see the x509v3_config(5) manual page for details of the extension section format.
-sigopt nm:vโ pass options to the signature algorithm during sign operations. You can give this one multiple times. The names and values you provide with it are algorithm-specific.-badsigโ corrupt the signature before writing it. Lowkey useful for testing ๐งช-digestโ the digest to use. This affects any signing or printing option that uses a message digest, such as the-fingerprint,-key, and-CAoptions. Any digest supported by theopenssl-dgst(1)command works. If not specified, thenSHA1is used with-fingerprint, or the default digest for the signing algorithm is used, typicallySHA256.
๐ Micro-CA Options ๐
-CA filename|uriโ specifies the"CA"certificate to be used for signing. When present, this behaves like a"micro CA", like so: the subject name of the"CA"certificate is placed as the issuer name in the new certificate, which is then signed using the"CA"key given as detailed below.
This option cannot be used in conjunction with -key (or -signkey). It's normally combined with the -req option referencing a CSR. Without the -req option, the input must be an existing certificate unless the -new option is given, which generates a certificate from scratch.
-CAform DER|PEM|P12,โ the format for the CA certificate; unspecified by default. Seeopenssl-format-options(1)for details.-CAkey filename|uriโ sets the CA private key to sign a certificate with. The private key must match the public key of the certificate given with-CA. If you don't provide this option, then the key must be present in the-CAinput.-CAkeyform DER|PEM|P12โ the format for the CA key; unspecified by default. Seeopenssl-format-options(1)for details.-CAserial filenameโ sets the CA serial number file to use.
When creating a certificate with this option and with the -CA option, the certificate serial number gets stored in the given file. This file consists of one line containing an even number of hex digits with the serial number used last time. After reading this number, it's incremented and used, and the file is updated.
The default filename is the CA certificate file base name with .srl appended. For example, if the CA certificate file is called mycacert.pem it expects to find a serial number file called mycacert.srl.
If the -CA option is specified and neither <-CAserial> or <-CAcreateserial> is given and the default serial number file does not exist, a random number is generated; this is the recommended practice. โจ
-CAcreateserialโ with this option and the-CAoption, the CA serial number file is created if it doesn't exist. A random number is generated, used for the certificate, and saved into the serial number file determined as described above.
๐ซถ Trust Settings ๐ซถ
A trusted certificate is just an ordinary certificate that has several extra pieces of information attached to it, like the permitted and prohibited uses of the certificate and possibly an "alias" (nickname). Main character with a nickname? We love to see it.
Normally when a certificate is being verified, at least one certificate must be "trusted". By default a trusted certificate must be stored locally and must be a root CA: any certificate chain ending in this CA is then usable for any purpose.
Trust settings currently are only used with a root CA. They allow finer control over the purposes the root CA can be used for. For example, a CA may be trusted for SSL client but not SSL server use.
See openssl-verification-options(1) for more info on what trust settings actually mean.
Future versions of OpenSSL will recognize trust settings on any certificate: not just root CAs. ๐ฎ
-trustoutโ mark any certificate PEM output as<trusted>certificate rather than ordinary. An ordinary or trusted certificate can be input, but by default an ordinary certificate is output and any trust settings are discarded. With-trustouta trusted certificate is output. A trusted certificate is automatically output if any trust settings are modified.-setalias argโ sets the"alias"of the certificate. This lets the certificate be referred to using a nickname, for example"Steve's Certificate".-clrtrustโ clears all the permitted or trusted uses of the certificate.-addtrust argโ adds a trusted certificate use. Any object name can be used here, but currently onlyclientAuth,serverAuth,emailProtection, andanyExtendedKeyUsageare defined. As of OpenSSL 1.1.0, that last one blocks all purposes when rejected, or enables all purposes when trusted. Other OpenSSL applications may define additional uses.-clrrejectโ clears all the prohibited or rejected uses of the certificate.-addreject argโ adds a prohibited trust anchor purpose. It accepts the same values as the-addtrustoption.
โจ Generic options โจ
-rand files,-writerand fileโ see"Random State Options"inopenssl(1)for details.-provider name-provider-path path-provparam [name:]key=value-propquery propqโ see"Provider Options"inopenssl(1),provider(7), andproperty(7).
As well as customising the name printing format, you can also pick and choose which actual fields get printed โ that's the certopt option doing its thing, but it only works when text is also in the mix. Default vibe? Everything gets printed, no skips. ๐
compatibleโ brings back the old format. Same energy as passing literally zero printing options. Nostalgia core.no_headerโ skip the header info, aka those little lines that sayCertificateandData.no_versionโ the version number stays unprinted. Not invited to the party.no_serialโ no serial number for you.no_signameโ the signature algorithm used isn't printed. Shy behavior honestly.no_validityโ validity is not printed, meaning thenotBeforeandnotAfterfields get skipped.no_subjectโ the subject name is staying home.no_issuerโ issuer name? not printed. ๐no_pubkeyโ the public key isn't printed out.no_sigdumpโ you don't get a hexadecimal dump of the certificate signature.no_auxโ certificate trust information isn't printed.no_extensionsโ zero X509V3 extensions printed. none. gone. โจext_defaultโ keeps the default extension behaviour: it attempts to print out certificate extensions that aren't supported.ext_errorโ prints an error message for unsupported certificate extensions instead.ext_parseโ does an ASN1 parse on unsupported extensions.ext_dumpโ hex dumps unsupported extensions.ca_defaultโ this is the valueopenssl-ca(1)uses, and it's equivalent tono_issuer,no_pubkey,no_header, andno_versionall together. the group chat bundle ๐ซถ
๐ EXAMPLES ๐
okay quick heads up bestie: in all of these, when you see a \, that means the example is supposed to be all on one line. it's a line-continuation thing, not a "type the backslash" thing. ๐
Print the contents of a certificate:
openssl x509 -in cert.pem -noout -text
Print the "Subject Alternative Name" extension of a certificate:
openssl x509 -in cert.pem -noout -ext subjectAltName
Print more extensions of a certificate:
openssl x509 -in cert.pem -noout -ext subjectAltName,nsCertType
Print the certificate serial number:
openssl x509 -in cert.pem -noout -serial
Print the certificate subject name:
openssl x509 -in cert.pem -noout -subject
Print the certificate subject name in RFC2253 form:
openssl x509 -in cert.pem -noout -subject -nameopt RFC2253
Print the certificate subject name in oneline form on a terminal supporting UTF8:
openssl x509 -in cert.pem -noout -subject -nameopt oneline,-esc_msb
Print the certificate SHA1 fingerprint:
openssl x509 -sha1 -in cert.pem -noout -fingerprint
Convert a certificate from PEM to DER format:
openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER
Convert a certificate to a certificate request:
openssl x509 -x509toreq -in cert.pem -out req.pem -key key.pem
Convert a certificate request into a self-signed certificate using extensions for a CA:
openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions v3_ca \
-key key.pem -out cacert.pem
Sign a certificate request using the CA certificate above and add user certificate extensions:
openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \
-CA cacert.pem -CAkey key.pem -CAcreateserial
Set a certificate to be trusted for SSL client use and change set its alias to "Steve's Class 1 CA"
openssl x509 -in cert.pem -addtrust clientAuth \
-setalias "Steve's Class 1 CA" -out trust.pem
Check if any certificates in a chain are due to expire within the next 30 days (returns zero if none will expire, nonzero if any will expire):
openssl x509 -in chain.pem -multi -checkend $[3600*24*30] \
&& echo 'perform renewal' || echo 'renewal unnecessary'
๐ NOTES ๐
The conversion to UTF8 format that the name options use assumes T61Strings are using the ISO8859-1 character set. wild, because that's actually wrong โ but Netscape and MSIE do it this way, and so do a whole lot of certificates. So yeah, it's incorrect, but it's way more likely to print the majority of certificates correctly. choosing incorrectness that works, iconic honestly. ๐ญ
The -email option searches the subject name and the subject alternative name extension. Only unique email addresses get printed โ it won't print the same address more than once. no duplicates, we keep it clean. โจ
๐ BUGS ๐
ngl you can end up producing invalid certificates or requests by specifying the wrong private key, by using unsuitable X.509 extensions, or by using inconsistent options in some cases. these should be checked. please check them. โ ๏ธ
There should be options to explicitly set things like start and end dates rather than only an offset from the current time. it's giving "missing feature" fr fr.
๐ SEE ALSO ๐
openssl(1)openssl-req(1)openssl-ca(1)openssl-genrsa(1)openssl-gendsa(1)openssl-verify(1)config(5)x509v3_config(5)
๐ HISTORY ๐
The hash algorithm used in the -subject_hash and -issuer_hash options before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding of the distinguished name. In OpenSSL 1.0.0 and later, it's based on a canonical version of the DN using SHA1. Which means any directories still using the old form have to get their links rebuilt with openssl-rehash(1) or something similar. sorry to that one directory. ๐ซถ
The -signkey option got renamed to -key in OpenSSL 3.0, and the old name is kept as an alias. so it's fine either way, lowkey.
The -C option was removed in OpenSSL 3.0.
Since OpenSSL 3.2, generated certificates bear X.509 version 3, and key identifier extensions are included by default. slay โจ
The -engine option was removed in OpenSSL 4.0.
OpenSSL 4.0 added support for specifying extensions to add via the default configuration file. See -extfile above for details.
As of OpenSSL 4.0, the x509 utility no longer has specialised built-in logic to add the SKID or AKID extensions โ they're handled through configuration files and command-line options just like any other extension. no special treatment, periodt. ๐
ยฉ๏ธ COPYRIGHT ยฉ๏ธ
Copyright 2000-2026 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
okay that's the whole page, bestie, you made it to the end ๐ this was version 4.0.3, dated 2026-09-29, and it's the OPENSSL-X509(1SSL) manual page. go forth and inspect some certs, you absolute main character. ๐๐ฆ
๐ฆ where this page comes from
- ubuntu stonking: openssl 4.0.3-1ubuntu1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms