OPENSSL(1)
🦋 OPENSSL(1) — General Commands Manual 🦋
okay so bestie, before anything else: yes, this is the OPENSSL(1) page, from the General Commands Manual, and yes it is a whole entire journey. grab a snack. 💖
✨ NAME ✨
openssl — the OpenSSL command line tool. that's it. that's the name. iconic behaviour honestly.
🌸 SYNOPSIS 🌸
openssl command [command_opt ...] [command_arg ...]
openssl list-standard-commands | list-message-digest-commands |
list-cipher-commands | list-cipher-algorithms |
list-message-digest-algorithms | list-public-key-algorithms
openssl no-command
💅 DESCRIPTION 💅
So OpenSSL is a cryptography toolkit — it implements the Transport Layer Security (TLS) network protocol, plus all the related cryptography standards that come with that whole world. 🔥
The openssl program itself is a command line tool that lets you use all the various cryptography functions of openssl's crypto library straight from the shell. no cap, it's your bestie for crypto stuff.
Now, the pseudo-commands. These are the little weirdos that don't do crypto, they just tell you about stuff:
list-standard-commands,list-message-digest-commands, andlist-cipher-commandsoutput a list (one entry per line) of the names of all standard commands, message digest commands, or cipher commands, respectively, that are available in the presentopensslutility.list-cipher-algorithmsandlist-message-digest-algorithmslist all cipher and message digest names, one entry per line. And when there are aliases, they get listed like this:
from => to
list-public-key-algorithmslists all supported public key algorithms. slay.
Then there's the weird little no-command pseudo-command — it tests whether a command of the specified name is available. here's the tea:
- if
commanddoes not exist, it returns0and printsno-command; - otherwise it returns
1and printscommand.
In both cases the output goes to stdout and nothing is printed to stderr. Additional command line arguments are always ignored. And because for each cipher there is a command of the same name, this gives shell scripts a super easy way to test for the availability of ciphers in the openssl program. 🫶
⚠️ Note:no-commandis not able to detect pseudo-commands such asquit,list-...-commands, orno-commanditself. so don't come for it.
🎀 ASN1PARSE 🎀
openssl asn1parse [-i] [-dlimit number] [-dump] [-genconf file]
[-genstr str] [-in file] [-inform der | pem | txt]
[-length number] [-noout] [-offset number]
[-oid file] [-out file] [-strparse offset]
The asn1parse command is a diagnostic utility that can parse ASN.1 structures. it can also be used to extract data from ASN.1 formatted data. multitasking queen. 👑
The options are as follows:
-dlimit number— dump the first number bytes of unknown data in hex form.-dump— dump unknown data in hex form. that's the whole thing, bestie.-genconf file,-genstr str— generate encoded data based on string str, file file, or both, using the format described inASN1_generate_nconf(3). If only file is present then the string is obtained from the default section using the name “asn1”. The encoded data is passed through the ASN.1 parser and printed out as though it came from a file; the contents can thus be examined and written to a file using the-outoption. ✨-i— indent the output according to the "depth" of the structures. it's giving aesthetic.-in file— the input file to read from, or standard input if not specified.-inform der | pem | txt— the input format.-length number— number of bytes to parse; the default is until end of file.-noout— do not output the parsed version of the input file.-offset number— starting offset to begin parsing; the default is start of file.-oid file— a file containing additional object identifiers (OIDs). If an OID (object identifier) is not part of openssl's internal table, it will be represented in numerical form (for example1.2.3.4).
Each line consists of three columns: the first column is the OID in numerical format and should be followed by whitespace. The second column is the "short name", which is a single word followed by whitespace. The final column is the rest of the line and is the "long name". asn1parse displays the long name. 📝
-out file— the DER-encoded output file; the default is no encoded output (useful when combined with-strparse).-strparse offset— parse the content octets of the ASN.1 object starting at offset. This option can be used multiple times to "drill down" into a nested structure. nesting doll energy 🪆
💜 CA 💜
openssl ca [-batch] [-cert file] [-config file] [-create_serial]
[-crl_CA_compromise time] [-crl_compromise time]
[-crl_hold instruction] [-crl_reason reason] [-crldays days]
[-crlexts section] [-crlhours hours] [-crlsec seconds]
[-days arg] [-enddate date] [-extensions section]
[-extfile file] [-gencrl] [-in file] [-infiles]
[-key password] [-keyfile file] [-keyform pem | der]
[-md alg] [-multivalue-rdn] [-name section] [-noemailDN]
[-notext] [-out file] [-outdir directory] [-passin arg]
[-policy arg] [-preserveDN] [-revoke file] [-selfsign]
[-sigopt nm:v] [-ss_cert file] [-startdate date]
[-status serial] [-subj arg] [-updatedb] [-utf8] [-verbose]
The ca command is a minimal certificate authority (CA) application. it can be used to sign certificate requests in a variety of forms and generate certificate revocation lists (CRLs). it also maintains a text database of issued certificates and their status. she does it all. 💅
The options relevant to CAs are as follows:
-batch— batch mode. In this mode no questions will be asked and all certificates will be certified automatically. no small talk, just vibes. 😌-cert file— the CA certificate file.-config file— specify an alternative configuration file.-create_serial— if reading the serial from the text file as specified in the configuration fails, create a new random serial to be used as the next serial number.-days arg— the number of days to certify the certificate for.-enddate date— set the expiry date. The format of the date is[YY]YYMMDDHHMMSSZ, with all four year digits required for dates from 2050 onwards. ⏰-extensions section— the section of the configuration file containing certificate extensions to be added when a certificate is issued (defaults tox509_extensionsunless the-extfileoption is used). If no extension section is present, a V1 certificate is created. If the extension section is present (even if it is empty), then a V3 certificate is created. See thex509v3.cnf(5)manual page for details of the extension section format.-extfile file— an additional configuration file to read certificate extensions from (using the default section unless the-extensionsoption is also used).-in file— an input file containing a single certificate request to be signed by the CA.-infiles— if present, this should be the last option; all subsequent arguments are assumed to be the names of files containing certificate requests. so like, put it last, bestie. 🙈-key password— the password used to encrypt the private key. Since on some systems the command line arguments are visible, this option should be used with caution.-keyfile file— the private key to sign requests with.-keyform pem | der— private key file format. The default ispem.-md alg— the message digest to use. Possible values includemd5andsha1. This option also applies to CRLs.-multivalue-rdn— this option causes the-subjargument to be interpreted with full support for multivalued RDNs, for example"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe". If-multivalue-rdnis not used, the UID value is set to"123456+CN=John Doe". 🧚-name section— specifies the configuration file section to use (overridesdefault_cain thecasection).-noemailDN— the DN of a certificate can contain the EMAIL field if present in the request DN, however it is good policy just having the email set into the altName extension of the certificate. When this option is set, the EMAIL field is removed from the certificate's subject and set only in the, eventually present, extensions. Theemail_in_dnkeyword can be used in the configuration file to enable this behaviour.-notext— don't output the text form of a certificate to the output file.-out file— the output file to output certificates to. The default is standard output. The certificate details will also be printed out to this file in PEM format.-outdir directory— the directory to output certificates to. The certificate will be written to a file consisting of the serial number in hex with.pemappended. 📁-passin arg— the key password source.-policy arg— define the CA "policy" to use. The policy section in the configuration file consists of a set of variables corresponding to certificate DN fields. The values may be one of"match"(the value must match the same field in the CA certificate),"supplied"(the value must be present), or"optional"(the value may be present). Any fields not mentioned in the policy section are silently deleted, unless the-preserveDNoption is set, but this can be regarded more of a quirk than intended behaviour. 💀-preserveDN— normally, the DN order of a certificate is the same as the order of the fields in the relevant policy section. When this option is set, the order is the same as the request. This is largely for compatibility with the older IE enrollment control which would only accept certificates if their DNs matched the order of the request. This is not needed for Xenroll.-selfsign— indicates the issued certificates are to be signed with the key the certificate requests were signed with, given with-keyfile. Certificate requests signed with a different key are ignored. If-gencrlor-ss_certare given,-selfsignis ignored.
A consequence of using -selfsign is that the self-signed certificate appears among the entries in the certificate database (see the configuration option database) and uses the same serial number counter as all other certificates signed with the self-signed certificate. 🔥
-sigopt nm:v— pass options to the signature algorithm during sign or certify operations. The names and values of these options are algorithm-specific.-ss_cert file— a single self-signed certificate to be signed by the CA.-startdatedate — sets the start date, bestie. Format is[YY]YYMMDDHHMMSSZ, and heads up: for any date from 2050 onwards you gotta give all four year digits. No shortcuts. 🗓️-subjarg — overrides the subject name from the request. arg has to be formatted like/type0=value0/type1=value1/type2=...; you can escape characters with\(backslash), and spoiler: no spaces are skipped. 🫶-utf8— treats field values read from a terminal or pulled from a config file as UTF-8 strings. Normally they're read as ASCII. 💅-verbose— prints extra deets about what's actually going on. 👀
The options that are all about CRLs are these ones:
-crl_CA_compromisetime — literally the same as-crl_compromise, except the revocation reason gets set toCACompromise.-crl_compromisetime — sets the revocation reason tokeyCompromiseand the compromise time to time. time should be in GeneralizedTime format, likeYYYYMMDDHHMMSSZ. ⏰-crl_holdinstruction — sets the CRL revocation reason code tocertificateHoldand the hold instruction to instruction, which must be an OID. Technically any OID works, but the ones you'd normally use areholdInstructionNone(which RFC 2459 discourages, ngl),holdInstructionCallIssuerorholdInstructionReject.-crl_reasonreason — the revocation reason, where reason is one of:unspecified,keyCompromise,CACompromise,affiliationChanged,superseded,cessationOfOperation,certificateHoldorremoveFromCRL. The matching is case insensitive. Setting any revocation reason makes the CRL v2. In practiceremoveFromCRLisn't really useful because it's only used in delta CRLs, which aren't currently implemented. 💀-crldaysdays — the number of days before the next CRL is due. That's the days from now that go into the CRLnextUpdatefield.-crlextssection — the config file section containing the CRL extensions to include. If there's no CRL extension section, you get a V1 CRL; if the section is there (even if it's empty!) you get a V2 CRL. The extensions specified are CRL extensions, not CRL entry extensions. And just so you know: some software genuinely can't handle V2 CRLs. Check thex509v3.cnf(5)manual page for the details of the extension section format. 🎀-crlhourshours — how many hours before the next CRL is due.-crlsecseconds — how many seconds before the next CRL is due.-gencrl— generates a CRL based on the info in the index file.-revokefile — a file containing a certificate to revoke. 🔥-statusserial — shows the status of the certificate with serial number serial.-updatedb— updates the database index to purge expired certificates. 🧹
A whole bunch of these options can be set in the ca section of the config file (or in the default section), specified using default_ca or -name. The preserve option is read directly from the ca section.
A lot of the config file options are literally identical to the command line options. When the option shows up in both the config file and the command line, the command line value wins. And if an option is described as mandatory, it has to be in the config file or you use the command line equivalent (if there is one). periodt. 💅
certificate— same as-cert. It's the file containing the CA certificate. Mandatory.copy_extensions— decides how extensions in certificate requests get handled. If it's set tonone, or the option isn't there at all, then extensions are ignored and not copied to the certificate. If it's set tocopy, then any extensions in the request that aren't already present get copied to the certificate. If it's set tocopyall, then all extensions in the request get copied to the certificate — and if the extension is already present in the certificate, it gets deleted first.
⚠️ Usecopy_extensionswith caution, fr. If you're not careful it can be a security risk. Like, if a certificate request contains abasicConstraintsextension withCA:TRUEandcopy_extensionsis set tocopyall, and the user doesn't spot it when the certificate is displayed, then you've just handed the requester a valid CA certificate. 😭
You can dodge that whole situation by setting copy_extensions to copy and including basicConstraints with CA:FALSE in the config file. Then if the request contains a basicConstraints extension, it just gets ignored. ✨
The main use of this option is letting a certificate request supply values for certain extensions like subjectAltName.
crl_extensions— same as-crlexts.crlnumber— a text file containing the next CRL number to use, in hex. The CRL number only gets inserted into CRLs if this file exists. And if the file is there, it must contain a valid CRL number.database— the text database file to use. Mandatory. The file has to be present, even though it'll be empty at first.default_crl_hours,default_crl_days— same as the-crlhoursand-crldaysoptions. These only get used if neither command line option is present. At least one of them must be there to generate a CRL.default_days— same as the-daysoption. The number of days to certify a certificate for.default_enddate— same as the-enddateoption. Either this one ordefault_days(or the command line equivalents) must be present.default_md— same as the-mdoption. The message digest to use. Mandatory.default_startdate— same as the-startdateoption. The start date to certify a certificate for. If it's not set, the current time is used. ⏳email_in_dn— same as-noemailDN. If the EMAIL field should be removed from the DN of the certificate, just set this to"no". If it's not present, the default is to allow the EMAIL field in the certificate's DN.name_opt,cert_opt— these let you set the format used to display the certificate details when the user is asked to confirm signing. All the options supported by the x509 utilities'-nameoptand-certoptswitches can be used here, except thatno_signameandno_sigdumpare permanently set and can't be disabled (that's because the certificate signature can't be displayed — the certificate hasn't been signed yet at this point, duh 💀).
For convenience, the value ca_default is accepted by both to produce reasonable output.
If neither option is present, the format used in earlier versions of openssl is used. Using the old format is strongly discouraged because it only displays fields mentioned in the policy section, mishandles multicharacter string types, and doesn't display extensions. 🙈
new_certs_dir— same as the-outdircommand line option. It specifies the directory where new certificates get placed. Mandatory.oid_file— specifies a file containing additional object identifiers. Each line should be the numerical form of the object identifier, then whitespace, then the short name, then whitespace, and finally the long name.oid_section— specifies a section in the config file containing extra object identifiers. Each line should be the short name of the object identifier, then=, then the numerical form. The short and long names are the same when you use this option.policy— same as-policy. Mandatory.preserve— same as-preserveDN.private_key— same as the-keyfileoption. The file containing the CA private key. Mandatory. 🔑serial— a text file containing the next serial number to use, in hex. Mandatory. This file must be present and contain a valid serial number.unique_subject— if the valueyesis given, the valid certificate entries in the database must have unique subjects. If the valuenois given, several valid certificate entries may have the exact same subject. Default isyes.
Note that it's valid in some circumstances for certificates to be created with no subject at all. And when there are multiple certificates without subjects, that doesn't count as a duplicate. 🦋
x509_extensions— same as-extensions.
🌸 CERTHASH 🌸
openssl certhash [-nv] dir ...
The certhash command calculates a hash value of a .pem file in the directory list you specify, and creates symbolic links for each file, where the name of the link is the hash value. Peep the SSL_CTX_load_verify_locations(3) manual page for how hash links get used. 🔗
The links it creates look like "HHHHHHHH.D", where each H is a hexadecimal character and D is a single decimal digit. The hashes for CRLs look similar, except there's a little r after the period, like this: "HHHHHHHH.rD". When it's processing a directory, certhash first removes all links that have a name in that syntax and are an invalid reference. 🧹
Multiple objects can have the same hash — they get indicated by incrementing the D value. Duplicates are found by comparing the full SHA256 fingerprint. A warning gets displayed if a duplicate is found. 👀
A warning also gets displayed if there are files that can't be parsed as either a certificate or a CRL.
The options are as follows:
-n— do a dry-run, don't make any changes.-v— print extra deets about the processing.dir ...— specify the directories to process. 🎀
✨ CIPHERS ✨
openssl ciphers [-hsVv] [-tls1_2] [-tls1_3] [control]
okay so the ciphers command is like a little translator bestie 💬 — it takes your control string (the one in that format documented over in SSL_CTX_set_cipher_list(3)) and turns it into an ordered SSL cipher suite preference list. And if you don't hand it a control string at all? No worries, it just prints the DEFAULT list for you. slay.
The options are as follows:
-h,-?— print a brief usage message. very demure, very helpful 🎀-s— only list ciphers that are actually supported by the TLS method. no fake ones allowed 💅-tls1_2|-tls1_3— pair this with the-soption and it'll list the ciphers that could be used if the specified protocol version were negotiated 👀-V— Verbose mode. It lists ciphers with the cipher suite code in hex format, the cipher name, plus a complete description of protocol version, key exchange, authentication, encryption, and mac algorithms. literally the full tea ☕-v— like-V, but without the cipher suite codes. same energy, less clutter ✨
💌 CMS 💌
openssl cms [-aes128 | -aes192 | -aes256 | -camellia128 |
-camellia192 | -camellia256 | -des | -des3 |
-rc2-40 | -rc2-64 | -rc2-128] [-CAfile file]
[-CApath directory] [-CRLfile file] [-binary]
[-certfile file] [-certsout file] [-cmsout] [-content file]
[-crlfeol] [-data_create] [-data_out] [-debug_decrypt]
[-decrypt] [-digest_create] [-digest_verify]
[-econtent_type type] [-encrypt] [-EncryptedData_decrypt]
[-EncryptedData_encrypt] [-from addr] [-in file]
[-inform der | pem | smime] [-inkey file]
[-keyform der | pem] [-keyid] [-keyopt nm:v] [-md digest]
[-no_attr_verify] [-no_content_verify]
[-no_signer_cert_verify] [-noattr] [-nocerts] [-nodetach]
[-nointern] [-nooldmime] [-noout] [-nosigs] [-nosmimecap]
[-noverify] [-out file] [-outform der | pem | smime]
[-passin src] [-print] [-pwri_password arg]
[-rctform der | pem | smime]
[-receipt_request_all | -receipt_request_first]
[-receipt_request_from addr] [-receipt_request_print]
[-receipt_request_to addr] [-recip file] [-resign]
[-secretkey key] [-secretkeyid id] [-sign] [-sign_receipt]
[-signer file] [-stream | -indef | -noindef] [-subject s]
[-text] [-to addr] [-verify] [-verify_receipt file]
[-verify_retcode] [cert.pem ...]
The cms command handles S/MIME v3.1 mail 🦋 — like, it can encrypt, decrypt, sign and verify S/MIME messages. it's giving "email but make it secure" and honestly? iconic.
⚠️ the MIME message must be sent without any blank lines between the headers and the output. Some mail programs will automatically add a blank line (rude 😭). Piping the mail directly to sendmail is one way to achieve the correct format.
The supplied message to be signed or encrypted must include the necessary MIME headers, or many S/MIME clients won't display it properly (if at all) 😬. You can use the -text option to automatically add plain text headers — problem solved bestie 💅
A "signed and encrypted" message is one where a signed message is then encrypted. This can be produced by encrypting an already signed message. no cap, that's the whole vibe 🔥
There are various operation options that set the type of operation to be performed. The meaning of the other options varies according to the operation type. iykyk 🫶
-encrypt— Encrypt mail for the given recipient certificates. The input file is the message to be encrypted. The output file is the encrypted mail in MIME format. The actual CMS type isEnvelopedData. Note that no revocation check is done for the recipient cert, so if that key has been compromised, others may be able to decrypt the text. like, actual danger, be aware 💀-decrypt— Decrypt mail using the supplied certificate and private key. It expects an encrypted mail message in MIME format for the input file. The decrypted mail is written to the output file. 🎀-sign— Sign mail using the supplied certificate and private key. Input file is the message to be signed. The signed message in MIME format is written to the output file. main character move ✍️-verify— Verify signed mail. Expects a signed mail message on input and outputs the signed data. Both clear text and opaque signing are supported. ✅-cmsout— Take an input message and write out a PEM encoded CMS structure. 🧾-resign— Resign a message. Takes an existing message and one or more new signers. This operation uses an existing message digest when adding a new signer. This means that attributes must be present in at least one existing signer using the same message digest or this operation will fail. 🙈-data_create— Create a CMSDatatype.-data_out— Output a content from the input CMSDatatype.-digest_create— Create a CMSDigestedDatatype.-digest_verify— Verify a CMSDigestedDatatype and output the content.-EncryptedData_encrypt— Encrypt a content using supplied symmetric key and algorithm using a CMSEncryptedDatatype.-EncryptedData_decrypt— Decrypt a CMSEncryptedDatatype using supplied symmetric key.-sign_receipt— Generate and output a signed receipt for the supplied message. The input message must contain a signed receipt request. Functionality is otherwise similar to the-signoperation. 💌-verify_receipt file— Verify a signed receipt in file. The input message must contain the original receipt request. Functionality is otherwise similar to the-verifyoperation.
The remaining options are as follows:
-aes128|-aes192|-aes256|-camellia128|-camellia192|-camellia256|-des|-des3|-rc2-40|-rc2-64|-rc2-128— The encryption algorithm to use. 128-, 192-, or 256-bit AES, 128-, 192-, or 256-bit CAMELLIA, DES (56 bits), triple DES (168 bits), or 40-, 64-, or 128-bit RC2, respectively; if not specified, 256-bit AES is used. Only used with-encryptand-EncryptedData_encryptcommands. 🌈-binary— Normally the input message is converted to "canonical" format, which is effectively using CR/LF as end of line, as required by the S/MIME specification. When this option is present, no translation occurs. This is useful when handling binary data which may not be in MIME format. 🧚-CAfile file— A file containing trusted CA certificates, used with-verifyand-verify_receipt.-CApath directory— A directory containing trusted CA certificates, used with-verifyand-verify_receipt. This directory must be a standard certificate directory: that is, a hash of each subject name (usingx509 -hash) should be linked to each certificate. 🔗-CRLfile file— Allows additional certificate revocation lists to be specified for verification. The CRLs should be in PEM format.cert.pem ...— One or more certificates of message recipients: used when encrypting a message. 📬-certfile file— Allows additional certificates to be specified. When signing, these will be included with the message. When verifying, these will be searched for the signer's certificates. The certificates should be in PEM format.-certsout file— A file that any certificates contained in the message are written to.-check_ss_sig,-crl_check,-crl_check_all,-extended_crl,-ignore_critical,-issuer_checks,-policy,-policy_check,-purpose,-x509_strict— Set various certificate chain validation options. See theverifycommand for details. 🕵️-content file— A file containing the detached content. This is only useful with the-verifycommand. This is only usable if the CMS structure is using the detached signature form where the content is not included. This option will override any content if the input format is S/MIME and it uses themultipart/signedMIME content type. 📎-crlfeol— Output a S/MIME message with CR/LF end of line.-debug_decrypt— Set theCMS_DEBUG_DECRYPTflag when decrypting. This option should be used with caution, since this can be used to disable the MMA attack protection and return an error if no recipient can be found. See theCMS_decrypt(3)manual page for details of the flag. like, bestie, be careful with this one 😭-from addr,-subject s,-to addr— The relevant mail headers. These are included outside the signed portion of a message so they may be included manually. If signing, then many S/MIME mail clients check the signer's certificate's email address matches that specified in theFrom:address. 👀-econtent_type type— Set the encapsulated content type, used with-sign. If not supplied, theDatatype is used. The type argument can be any valid OID name in either text or numerical format.-in file— The input message to be encrypted or signed or the message to be decrypted or verified.-inform der | pem | smime— The input format for the CMS structure. The default issmime, which reads an S/MIME format message.pemandderformat change this to expect PEM and DER format CMS structures instead. This currently only affects the input format of the CMS structure; if no CMS structure is being input (for example with-encryptor-sign) this option has no effect. 💅-inkey file— The private key to use when signing or decrypting. This must match the corresponding certificate. If this option is not specified then the private key must be included in the certificate file specified with the-recipor-signerfile. When signing, this option can be used multiple times to specify successive keys. 🔑-keyform der | pem— Input private key format. The default ispem.-keyid— Use subject key identifier to identify certificates instead of issuer name and serial number. The supplied certificate must include a subject key identifier extension. Supported by-signand-encryptoperations. 🪪-keyopt nm:v— Set customised parameters for the preceding key or certificate for encryption and signing. It can currently be used to set RSA-PSS for signing, RSA-OAEP for encryption or to modify default parameters for ECDH. This option can be used multiple times. ✨-md digest— The digest algorithm to use when signing or resigning. If not present then the default digest algorithm for the signing key will be used (usuallySHA1).-no_attr_verify— Do not verify the signer's attribute of a signature.-no_content_verify— Do not verify the content of a signed message.-no_signer_cert_verify— ok so this one tells the signer's certificate of a signed message to chill, no verification, we're not checking it 💅-noattr— no attributes, periodt. Normally when a message gets signed, a whole lil set of attributes rides along — signing time, supported symmetric algorithms, the works. Flip this on and nope, they're not included 🙈-nocerts— don't stuff the signer's certificate in there. Slay for file size (smaller signed message, iconic), but bestie listen — the verifier then must have a copy of the signer's certificate sitting locally, like passed in with the-certfileoption for example. No cert, no vibe check 🔥-nodetach— when signing, use opaque signing. This form is more resistant to translation by mail relays (main character energy against meddling relays) but it cannot be read by mail agents that do not support S/MIME 😭. Without this option, cleartext signing with the MIME typemultipart/signedis used.-nointern— only the certificates specified in the-certfileoption get used. Normally when verifying, certificates (if any) included in the message are searched for the signing certificate — with this, not so much. The supplied certificates can still be used as untrusted CAs however ✨-nooldmime— output an old S/MIME content type like"application/x-pkcs7-". Retro but make it vintage 🎀-noout— do not output the parsed CMS structure for the-cmsoutoperation. So useful when combined with the-printoption, or if you're just checking the syntax of the CMS structure 🦋-nosigs— do not try to verify the signatures on the message. We're just not doing that today 🫶-nosmimecap— exclude the list of supported algorithms from signed attributes; other options such as signing time and content type are still included though, so don't worry, they're still there 💖-noverify— do not verify the signer's certificate of a signed message. Trust issues? No, just lazy 💀-outfile — the message text that has been decrypted or verified, or the output MIME format message that has been signed or verified. Everything goes here 🌸-outform der | pem | smime— this specifies the output format for the CMS structure. The default issmime, which writes an S/MIME format message.pemandderformat change this to write PEM and DER format CMS structures instead. Heads up tho: this currently only affects the output format of the CMS structure; if no CMS structure is being output (for example with-verifyor-decrypt) this option has no effect, literally none, it's just standing there 💅-passinsrc — the private key password source 🔑-print— print out all the fields of the CMS structure for the-cmsoutoperation. Mainly useful for testing purposes, iykyk 🧚-pwri_passwordarg — specify PasswordRecipientInfo (PWRI) password to use. Supported by the-encryptand-decryptoperations ✨-rctform der | pem | smime— specify the format for a signed receipt for use with the-receipt_verifyoperation. The default issmime🎀-receipt_request_all|-receipt_request_first— indicate requests should be provided by all recipient or first tier recipients (those mailed directly and not from a mailing list), for the-signoperation to include a signed receipt request. Ignored if-receipt_request_fromis included 🙈-receipt_request_fromaddr — add an explicit email address where receipts should be supplied 📬-receipt_request_print— print out the contents of any signed receipt requests for the-verifyoperation 🖨️-receipt_request_toaddr — add an explicit email address where signed receipts should be sent to. This option must be supplied if a signed receipt is requested — non-negotiable bestie 💅-recipfile — when decrypting a message, this specifies the recipient's certificate. The certificate must match one of the recipients of the message or an error occurs, no cap 😤. When encrypting a message, this option may be used multiple times to specify each recipient. This form must be used if customised parameters are required (for example to specify RSA-OAEP). Only certificates carrying RSA, Diffie-Hellman or EC keys are supported by this option 🔑-secretkeykey — specify symmetric key to use. The key must be supplied in hex format and be consistent with the algorithm used. Supported by the-EncryptedData_encrypt,-EncryptedData_decrypt,-encryptand-decryptoperations. When used with-encryptor-decrypt, the supplied key is used to wrap or unwrap the content encryption key using an AES key in the KEKRecipientInfo type 🔐-secretkeyidid — the key identifier for the supplied symmetric key for KEKRecipientInfo type. This option must be present if the-secretkeyoption is used with-encrypt. With-decryptoperations the id is used to locate the relevant key; if it is not supplied then an attempt is used to decrypt any KEKRecipientInfo structures 🕵️♀️-signerfile — a signing certificate when signing or resigning a message; this option can be used multiple times if more than one signer is required. If a message is being verified then the signers certificates will be written to this file if the verification was successful 👑-stream|-indef|-noindef— the-streamand-indefoptions are equivalent and enable streaming I/O for encoding operations. This permits single pass processing of data without the need to hold the entire contents in memory, potentially supporting very large files 🔥. Streaming is automatically set for S/MIME signing with detached data if the output format issmime; it is currently off by default for all other operations.-noindefdisable streaming I/O where it would produce an indefinite length constructed encoding. This option currently has no effect 💀-text— add plain text (text/plain) MIME headers to the supplied message if encrypting or signing. If decrypting or verifying, it strips off text headers: if the decrypted or verified message is not of MIME typetext/plainthen an error occurs 😭-verify_retcode— set verification error code to exit code to indicate what verification error has occurred. Supported by-verifyoperation only. Exit code value minus 32 shows verification error code. See verify command for the list of verification error code 🧚
The exit codes for cms are as follows:
0 The operation was completely successful.
1 An error occurred parsing the command options.
2 One of the input files could not be read.
3 An error occurred creating the CMS file or when reading the
MIME message.
4 An error occurred decrypting or verifying the message.
5 The message was verified correctly but an error occurred
writing out the signer's certificates.
6 An error occurred writing the output file.
32+ A verify error occurred while -verify_retcode is specified.
🌈 CRL 🌈
openssl crl [-CAfile file] [-CApath dir] [-crlnumber] [-fingerprint]
[-hash] [-hash_old] [-in file] [-inform der | pem]
[-issuer] [-lastupdate] [-nameopt option] [-nextupdate]
[-noout] [-out file] [-outform der | pem] [-text] [-verify]
The crl command processes CRL files in DER or PEM format. That's it, that's the whole vibe 🎀
The options are as follows:
-CAfilefile — verify the signature on a CRL by looking up the issuing certificate in file 🔍-CApathdirectory — verify the signature on a CRL by looking up the issuing certificate in dir. This directory must be a standard certificate directory, i.e. a hash of each subject name (usingx509 -hash) should be linked to each certificate. Respect the structure bestie 💅-crlnumber— print the CRL number 🔢-fingerprint— print the CRL fingerprint (ok that's not an emoji but you get it)-hash— output a hash of the issuer name. This can be used to look up CRLs in a directory by issuer name ✨-hash_old— output an old-style (MD5) hash of the issuer name. Vintage tech, we love a throwback 🎀-infile — the input file to read from, or standard input if not specified 📥-inform der | pem— the input format 🦋-issuer— output the issuer name 🏷️-lastupdate— output the thisUpdate field. This option is misnamed for historical reasons — yeah it's giving "we know, we know" 💀-nameoptoption — specify certificate name options 🌸-nextupdate— output the nextUpdate field ⏭️-noout— do not output the encoded version of the CRL 🙈-outfile — the output file to write to, or standard output if not specified 📤-outform der | pem— the output format 🌟-text— print the CRL in plain text (readable, iconic) 👑-verify— verify the signature on the CRL ✅
🦋 CRL2PKCS7 🦋
openssl crl2pkcs7 [-certfile file] [-in file] [-inform der | pem]
[-nocrl] [-out file] [-outform der | pem]
The crl2pkcs7 command takes an optional CRL and one or more certificates and converts them into a PKCS#7 degenerate "certificates only" structure. It's giving "glow-up but for data" ✨
The options are as follows:
-certfilefile — add the certificates in PEM file to the PKCS#7 structure. This option can be used more than once to read certificates from multiple files, stack 'em up 🥞-infile — read the CRL from file, or standard input if not specified 📥-inform der | pem— the input format 🦋-nocrl— normally, a CRL is included in the output file. With this option, no CRL is included in the output file and a CRL is not read from the input file. Bye bye CRL 👋-outfile — write the PKCS#7 structure to file, or standard output if not specified 📤-outform der | pem— the output format 🌟
🫶 DGST 🫶
openssl dgst [-cdr] [-binary] [-digest] [-hex] [-hmac key]
[-keyform pem] [-mac algorithm] [-macopt nm:v] [-out file]
[-passin arg] [-prverify file] [-sign file]
[-signature file] [-sigopt nm:v] [-verify file] [file ...]
Okay so the digest girlies 💅 — these functions spit out the message digest of a file (or files, she's generous) in hexadecimal form. But wait, there's more: they can also do digital signing and verification. Multitalented icon behavior, honestly.
Here's what the options do, bestie:
-binary— Output the digest or signature in binary form. Raw bytes, no cute hex dress-up.-c— Print the digest in two-digit groups separated by colons. Very aesthetic, very00:1a:2bof it.-d— Print BIO debugging information. Nerdy stuff, we love.-digest— Use the specified message digest. The default isSHA256. You can see all the available digests withopenssl list-message-digest-commands. And these two are literally equivalent:openssl dgst -sha256andopenssl sha256. Same vibe, same result ✨-hex— Digest is to be output as a hex dump. This is the default for a "normal" digest, as opposed to a digital signature.-hmac key— Create a hashed MAC usingkey.-keyform pem— Specifies the key format to sign the digest with.-mac algorithm— Create a keyed Message Authentication Code (MAC). The most popular MAC algorithm is HMAC (hash-based MAC), but there are other MAC algorithms that aren't based on hashes at all. MAC keys and other options get set via the-macoptparameter.-macopt nm:v— Passes options to the MAC algorithm that-macspecified. HMAC supports these two:key:string— Specifies the MAC key as an alphanumeric string. Use this if the key has printable characters only. String length must conform to any restrictions of the MAC algorithm.hexkey:string— Specifies the MAC key in hexadecimal form (two hex digits per byte). Key length must conform to any restrictions of the MAC algorithm.
-out file— The output file to write to, or standard output if you don't specify one.-passin arg— The key password source.-prverify file— Verify the signature using the private key infile. The output is eitherVerification OKorVerification Failure. High stakes, no in-between 💀-r— Print the digest in coreutils format.-sign file— Digitally sign the digest using the private key infile.-signature file— The actual signature to verify.-sigopt nm:v— Pass options to the signature algorithm during sign or verify operations. The names and values of these options are algorithm-specific.-verify file— Verify the signature using the public key infile. Output is eitherVerification OKorVerification Failure, same energy.file ...— The file or files to digest. If you don't name any files, standard input is used. Slurp from stdin, iconic.
🦋 DHPARAM 🦋
openssl dhparam [-2 | -5] [-check] [-dsaparam] [-in file]
[-inform der | pem] [-noout] [-out file]
[-outform der | pem] [-text] [numbits]
So dhparam is the command that manipulates DH parameter files. And important note, bestie: only the older PKCS#3 DH is supported, not the newer X9.42 DH. That's a real limitation, not a vibe — don't come for me.
The options, let's go:
-2,-5— The generator to use;2is the default. If you include one of these, the input file is ignored and parameters get generated instead. Out with the old, in with the new ✨-check— Check the DH parameters. A little vibe check, but for math.-dsaparam— Read or create DSA parameters, converted to DH format on output. Otherwise, "strong" primes are used for DH parameter generation — that means primes where(p-1)/2is also prime. DH parameter generation with the-dsaparamoption is much faster, and the recommended exponent length is shorter, which makes DH key exchange more efficient. But ⚠️ beware: with these DSA-style DH parameters, you should create a fresh DH key for each use, to avoid small-subgroup attacks that might be possible otherwise. No reusing keys here, that's the rule.-in file— The input file to read from, or standard input if you don't specify one.-inform der | pem— The input format.-noout— Do not output the encoded version of the parameters.-out file— The output file to write to, or standard output if not specified.-outform der | pem— The output format.-text— Print the DH parameters in plain text. Human-readable, thank god.numbits— Generate a parameter set of sizenumbits. It must be the last option (order matters, bestie). If you don't include it,2048is used. And if you do include it, the input file is ignored and parameters are generated instead.
🌸 DSA 🌸
openssl dsa [-aes128 | -aes192 | -aes256 | -des | -des3] [-in file]
[-inform der | pem | pvk] [-modulus] [-noout] [-out file]
[-outform der | pem | pvk] [-passin arg] [-passout arg]
[-pubin] [-pubout] [-pvk-none | -pvk-strong | -pvk-weak]
[-text]
The dsa command processes DSA keys. Converts them between various forms, prints their components out — a real glow-up station for your keys 🎀
⚠️ Note: this command uses the traditional SSLeay compatible format for private key encryption. Newer applications should use the more secure PKCS#8 format via the pkcs8 command. Read that again, it's important.
Options time:
-aes128|-aes192|-aes256|-des|-des3— Encrypt the private key with the AES, DES, or triple DES ciphers, respectively, before outputting it. You'll get a pass phrase prompt. If you specify none of these options, the key is written in plain text. Which means: using thedsautility to read an encrypted key with no encryption option can remove the pass phrase from a key — or, by setting the encryption options, it can add or change the pass phrase. Kind of a glow-up and a glow-down, depending on your goals 💅 These options only work with PEM format output files.-in file— The input file to read from, or standard input if not specified. If the key is encrypted, you'll get a pass phrase prompt.-inform der | pem | pvk— The input format.-modulus— Print the value of the public key component of the key.-noout— Do not output the encoded version of the key.-out file— The output file to write to, or standard output if not specified. If any encryption options are set, a pass phrase will be prompted for.-outform der | pem | pvk— The output format.-passin arg— The key password source.-passout arg— The output file password source.-pubin— Read in a public key, not a private key.-pubout— Output a public key, not a private key. Automatically set if the input is a public key. She just knows.-pvk-none|-pvk-strong|-pvk-weak— Enable or disable PVK encoding. The default is-pvk-strong.-text— Print the public/private key in plain text.
🧚 DSAPARAM 🧚
openssl dsaparam [-genkey] [-in file] [-inform der | pem] [-noout]
[-out file] [-outform der | pem] [-text] [numbits]
The dsaparam command manipulates or generates DSA parameter files. It's giving parameter factory, honestly 🔥
The options:
-genkey— Generate a DSA key using either the specified or generated parameters. Either way, you get a key out of it.-in file— The input file to read from, or standard input if not specified. If you include thenumbitsparameter, then this option is ignored. Sorry bestie,numbitswins.-inform der | pem— The input format.-noout— Do not output the encoded version of the parameters.-out file— The output file to write to, or standard output if not specified.-outform der | pem— The output format.-text— Print the DSA parameters in plain text.numbits— Generate a parameter set of sizenumbits. If this option is included, the input file is ignored. Periodt.
✨ EC ✨
openssl ec [-conv_form arg] [-des] [-des3] [-in file]
[-inform der | pem] [-noout] [-out file]
[-outform der | pem] [-param_enc arg] [-param_out]
[-passin arg] [-passout arg] [-pubin] [-pubout] [-text]
Okay so the ec command is literally the EC-key glow-up station 💅 — it processes EC keys, converts them between the various forms, and prints out their components. openssl uses the private key format specified in “SEC 1: Elliptic Curve Cryptography” (<https://www.secg.org/>). And heads up, bestie: if you wanna convert an EC private key into the PKCS#8 private key format, you use the pkcs8 command instead. Different tool, different vibe 🦋
The options are as follows:
-conv_form arg— specify how the points on the elliptic curve get converted into octet strings. Possible values are:compressed,uncompressed(the default), andhybrid. For more info on the point conversion forms, see the X9.62 standard 🌸-des|-des3— encrypt the private key with DES, triple DES, or any other cipher supported byopenssl. A pass phrase is prompted for. If none of these options are specified, the key is written in plain text. Which means: using theecutility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or, by setting the encryption options, it can be used to add or change the pass phrase. These options can only be used with PEM format output files 🔥-in file— the input file to read a key from, or standard input if not specified. If the key is encrypted, a pass phrase will be prompted for.-inform der | pem— the input format.-noout— do not output the encoded version of the key.-out file— the output filename to write to, or standard output if not specified. If any encryption options are set then a pass phrase will be prompted for.-outform der | pem— the output format.-param_enc arg— specify how the elliptic curve parameters are encoded. Possible values are:named_curve, i.e. the EC parameters are specified by an OID; orexplicit, where the EC parameters are explicitly given (see RFC 3279 for the definition of the EC parameter structures). The default value isnamed_curve. Note: theimplicitlyCAalternative, as specified in RFC 3279, is currently not implemented 🙈-param_out— print the elliptic curve parameters.-passin arg— the key password source.-passout arg— the output file password source.-pubin— read in a public key, not a private key.-pubout— output a public key, not a private key. Automatically set if the input is a public key.-text— print the public/private key in plain text.
🧚 ECPARAM 🧚
openssl ecparam [-check] [-conv_form arg] [-genkey] [-in file]
[-inform der | pem] [-list_curves] [-name arg]
[-no_seed] [-noout] [-out file] [-outform der | pem]
[-param_enc arg] [-text]
The ecparam command is used to manipulate or generate EC parameter files. Real talk though: openssl is not able to generate new groups, so ecparam can only create EC parameters from known (named) curves. That's just the way it is, no cap 💀
The options are as follows:
-check— validate the elliptic curve parameters.-conv_form arg— specify how the points on the elliptic curve get converted into octet strings. Possible values are:compressed,uncompressed(the default), andhybrid. For more info regarding the point conversion forms see the X9.62 standard 🌈-genkey— generate an EC private key using the specified parameters.-in file— the input file to read from, or standard input if not specified.-inform der | pem— the input format.-list_curves— print a list of all currently implemented EC parameter names and exit. Iconic lil directory dump 👑-name arg— use the EC parameters with the specified "short" name.-no_seed— do not include the seed for the parameter generation in theECParametersstructure (see RFC 3279).-noout— do not output the encoded version of the parameters.-out file— the output file to write to, or standard output if not specified.-outform der | pem— the output format.-param_enc arg— specify how the elliptic curve parameters are encoded. Possible values are:named_curve, i.e. the EC parameters are specified by an OID; orexplicit, where the EC parameters are explicitly given (see RFC 3279 for the definition of the EC parameter structures). The default value isnamed_curve. Note: theimplicitlyCAalternative, as specified in RFC 3279, is currently not implemented 🙈-text— print the EC parameters in plain text.
🔐 ENC 🔐
openssl enc -ciphername [-AadePpv] [-base64] [-bufsize number] [-debug]
[-in file] [-iter iterations] [-iv IV] [-K key]
[-k password] [-kfile file] [-md digest] [-none] [-nopad]
[-nosalt] [-out file] [-pass arg] [-pbkdf2] [-S salt]
[-salt]
The symmetric cipher commands let you encrypt or decrypt data using all kinds of block and stream ciphers, with keys based on passwords or keys you provide explicitly. Base64 encoding or decoding can also be performed either by itself or on top of the encryption/decryption — versatile queen 💅 The program can be called either as openssl ciphername or openssl enc -ciphername.
Okay so a lil reality check: some of the ciphers do not have large keys, and others have security implications if not used correctly 😭 Be mindful, bestie.
All the block ciphers normally use PKCS#5 padding, also known as standard block padding. If padding is disabled, the input data must be a multiple of the cipher block length. No exceptions, fr fr.
The options are as follows:
-A— if the-aoption is set, then base64 process the data on one line.-a,-base64— base64 process the data. This means that if encryption is taking place, the data is base64-encoded after encryption. If decryption is set, the input data is base64-decoded before being decrypted.-bufsize number— set the buffer size for I/O.-d— decrypt the input data.-debug— debug the BIOs used for I/O.-e— encrypt the input data. This is the default.-in file— the input file to read from, or standard input if not specified.-iter iterations— use the pbkdf2 key derivation function, with iterations as the number of iterations.-iv IV— the actual IV (initialisation vector) to use: this must be represented as a string comprised only of hex digits. When only the key is specified using the-Koption, the IV must explicitly be defined. When a password is being specified using one of the other options, the IV is generated from this password 🎀-K key— the actual key to use: this must be represented as a string comprised only of hex digits. If only the key is specified, the IV must also be specified using the-ivoption. When both a key and a password are specified, the key given with the-Koption will be used and the IV generated from the password will be taken. It probably does not make much sense to specify both key and password, ngl.-k password— the password to derive the key from. Superseded by the-passoption.-kfile file— read the password to derive the key from the first line of file. Superseded by the-passoption.-md digest— use digest to create a key from a pass phrase. Currently, the default value issha256.-none— use NULL cipher (no encryption or decryption of input).-nopad— disable standard block padding.-nosalt— don't use a salt in the key derivation routines.
🚨 Bestie, listen: this option should never be used, since it makes it possible to perform efficient dictionary attacks on the password and to attack stream cipher encrypted data. Like, never ever. Periodt.
-out file— the output file to write to, or standard output if not specified.-P— print out the salt, key, and IV used, then immediately exit; don't do any encryption or decryption.-p— print out the salt, key, and IV used.-pass arg— the password source.-pbkdf2— use the pbkdf2 key derivation function, with the default of10000iterations.-S salt— the actual salt to use: this must be represented as a string comprised only of hex digits.-salt— use a salt in the key derivation routines (the default). When the salt is being used, the first eight bytes of the encrypted data are reserved for the salt: it is randomly generated when encrypting a file and read from the encrypted file when it is decrypted 🌸-v— print extra details about the processing.
💀 ERRSTR 💀
openssl errstr errno ...
The errstr command performs error number to error string conversion, generating a human-readable string representing the error code errno. The string is obtained through the ERR_error_string_n(3) function and has the following format:
error:[error code]:[library name]:[function name]:[reason string]
[error code] is an 8-digit hexadecimal number. The remaining fields [library name], [function name], and [reason string] are all ASCII text. Cute lil decoder ring, iykyk 🦋
🎀 GENDSA 🎀
openssl gendsa [-aes128 | -aes192 | -aes256 | -camellia128 |
-camellia192 | -camellia256 | -des | -des3 | -idea]
[-out file] [-passout arg] paramfile
The gendsa command generates a DSA private key from a DSA parameter file (typically generated by the openssl dsaparam command). And here's the slay: DSA key generation is little more than random number generation, so it is much quicker than, for example, RSA key generation ⚡
The options are as follows:
-aes128|-aes192|-aes256|-camellia128|-camellia192|-camellia256|-des|-des3|-idea— encrypt the private key with the AES, CAMELLIA, DES, triple DES or the IDEA ciphers, respectively, before outputting it. A pass phrase is prompted for. If none of these options are specified, no encryption is used.-out file— the output file to write to, or standard output if not specified.-passout arg— the output file password source.paramfile— specify the DSA parameter file to use. The parameters in this file determine the size of the private key 💜
✨ GENPKEY ✨
openssl genpkey [-algorithm alg] [cipher] [-genparam] [-out file]
[-outform der | pem] [-paramfile file] [-pass arg]
[-pkeyopt opt:value] [-text]
Okay so genpkey makes private keys, and bestie, listen — use this one instead of the algorithm-specific utilities, because it lets you pile on extra algorithm options. It's giving main character energy and the old ones know it. 💅
🎀 The options, one by one 🎀
-algorithm alg— which public key algorithm you want, like RSA, DSA, or DH. Heads up: this has to come before any-pkeyoptoptions, or it'll be messy. Also-paramfileand-algorithmare mutually exclusive — pick a lane, babe. 🦋cipher— encrypt the private key with the cipher you pass in. Literally any algorithm name thatEVP_get_cipherbyname(3)accepts is fine here. 🔐-genparam— generate a set of parameters instead of a private key. And this one has to precede any-algorithm,-paramfile, or-pkeyoptoptions. Order matters, no cap. ✨-out file— the output file to write to, or standard output if you don't specify one. 🫶-outform der | pem— the output format. That's it, that's the whole thing. 🎀-paramfile file— some public key algorithms build a private key off a set of parameters, and this is where you feed those in. If you use it, the public key algorithm gets determined by the parameters. Must come before any-pkeyoptoptions. And again:-paramfileand-algorithmare mutually exclusive. 🌸-pass arg— the output file password source. 🗝️-pkeyopt opt:value— set the public key algorithm optionopttovalue, like so:rsa_keygen_bits:numbits— (RSA) how many bits go in the generated key. Default is2048. 💪rsa_keygen_pubexp:value— (RSA) the RSA public exponent value. It can be a big decimal, or hex if you slap0xin front. Default is65537. 🔢dsa_paramgen_bits:numbits— (DSA) how many bits in the generated parameters. Default is1024. ✨dh_paramgen_prime_len:numbits— (DH) how many bits in the prime parameterp. 🌈dh_paramgen_generator:value— (DH) the value to use for the generatorg. ⭐ec_paramgen_curve:curve— (EC) which elliptic curve to use. 🌀
-text— print the private/public key in plain text. Readable key, happy life. 🎀
🔥 GENRSA 🔥
openssl genrsa [-3 | -f4] [-aes128 | -aes192 | -aes256 | -camellia128 |
-camellia192 | -camellia256 | -des | -des3 | -idea]
[-out file] [-passout arg] [numbits]
genrsa generates an RSA private key, which is basically "make two prime numbers happen." 🌱 While it's generating, it prints little symbols so you can watch the progress like it's a livestream:
.— each number that passed an initial sieve test+— a number passed a single round of the Miller-Rabin primality test*— the number failed primality testing and needs to be generated afresh (rip, try again 💀)- a newline — the number passed all the prime tests (how many tests depends on the key size)
💖 Options 💖
-3|-f4— the public exponent to use, either3or65537. Default is65537. 👑-aes128|-aes192|-aes256|-camellia128|-camellia192|-camellia256|-des|-des3|-idea— encrypt the private key with AES, CAMELLIA, DES, triple DES, or the IDEA ciphers respectively before outputting it. If you don't pick any of these, there's no encryption at all. And if encryption is used, it prompts you for a pass phrase — unless you already handed it over with-passout. 🔐-out file— the output file to write to, or standard output if you don't specify one. 🫶-passout arg— the output file password source. 🗝️numbits— the size of the private key to generate, in bits. This one must be the last option specified (rules are rules). Default is2048. 💪
🌈 OCSP 🌈
openssl ocsp [-CA file] [-CAfile file] [-CApath directory] [-cert file]
[-dgst alg] [-header name value] [-host hostname:port]
[-ignore_err] [-index indexfile] [-issuer file]
[-ndays days] [-nmin minutes] [-no_cert_checks]
[-no_cert_verify] [-no_certs] [-no_chain] [-no_explicit]
[-no_intern] [-no_nonce] [-no_signature_verify] [-nonce]
[-noverify] [-nrequest number] [-out file] [-path path]
[-port portnum] [-req_text] [-reqin file] [-reqout file]
[-resp_key_id] [-resp_no_certs] [-resp_text]
[-respin file] [-respout file] [-rkey file] [-rother file]
[-rsigner file] [-serial num] [-sign_other file]
[-signer file] [-signkey file] [-status_age age] [-text]
[-timeout seconds] [-trust_other] [-url responder_url]
[-VAfile file] [-validity_period nsec]
[-verify_other file]
The Online Certificate Status Protocol (OCSP) is how applications find out the (revocation) state of a certificate they've identified — and yes, it's specified in RFC 2560, we love a documented vibe. 📜
So ocsp does a whole bunch of common OCSP tasks at once: it prints out requests and responses, creates requests, sends queries off to an OCSP responder, and can even act like a mini OCSP server itself. Multi-talented. Iconic. 💅
🦋 The options 🦋
-CAfile file,-CApath directory— a file or path holding trusted CA certificates, used to verify the signature on the OCSP response. 🎀-cert file— add the certificate file to the request. The issuer certificate comes from the previous-issueroption — and if no issuer certificate was specified, you get an error, periodt. ⚠️-dgst alg— use the digest algorithmalgfor certificate identification in the OCSP request. It'sSHA1by default. 🔍-host hostname:port,-path path— send the OCSP request tohostnameonport.-pathsets the HTTP path name to use, or/by default. 🌐-header name value— add the headernamewith the givenvalueto the OCSP request being sent to the responder. You can repeat this one as many times as you want. 📨-issuer file— the current issuer certificate, in PEM format. Can be used multiple times, and it must come before any-certoptions. 🗂️-no_cert_checks— don't do any additional checks on the OCSP response signer's certificate. Like, no checks at all on whether that signer's cert is even authorised to provide the status info you asked for. Because of that, only use this for testing. 🙈-no_cert_verify— don't verify the OCSP response signer's certificate at all. Since this lets the OCSP response be signed by any certificate, yeah… testing purposes only, bestie. 💀-no_certs— don't include any certificates in the signed request. 🚫-no_chain— don't use certificates in the response as additional untrusted CA certificates. ⛓️-no_explicit— don't check for explicit trust for OCSP signing in the root CA certificate. 🌱-no_intern— ignore certificates contained in the OCSP response when searching for the signer's certificate. If you use this, the signer's certificate has to be specified with either the-verify_otheror-VAfileoptions. 🔎-no_signature_verify— don't check the signature on the OCSP response. Since this tolerates invalid signatures on OCSP responses, it'll normally only be used for testing. 😭-nonce,-no_nonce— add an OCSP nonce extension to a request, or disable adding one. Normally, if an OCSP request comes in via-respin, no nonce gets added — but-nonceforces one in. And if an OCSP request is being created (with-certand-serial), a nonce is added automatically, and-no_nonceoverrides that. 🎲-noverify— don't even attempt to verify the OCSP response signature or the nonce values. Normally this is only for debugging, since it disables all verification of the responder's certificate. 🐛-out file— the output file to write to, or standard output if you don't specify one. 🫶-req_text,-resp_text,-text— print out the text form of the OCSP request, the response, or both, respectively. 📝-reqin file,-respin file— read an OCSP request or response file fromfile. These get ignored if creating an OCSP request or response is implied by other options (say, with the-serial,-cert, and-hostoptions). 📥-reqout file,-respout file— write out the DER-encoded certificate request or response tofile. 📤-serial num— same as the-certoption, except the certificate with serial numbernumgets added to the request. The serial number is read as a decimal integer unless it starts with0x. Negative integers work too — just put a minus sign in front. 🔢-sign_other file— extra certificates to include in the signed request. 🎁-signer file,-signkey file— sign the OCSP request using the certificate given in-signerand the private key given by-signkey. If there's no-signkey, the private key gets read from the same file as the certificate. If neither option is present, the OCSP request just… isn't signed. 🤷♀️-timeout seconds— connection timeout to the OCSP responder, in seconds. ⏱️-trust_other— the certificates given by-verify_othershould be explicitly trusted, and no additional checks get performed on them. Super useful when the complete responder certificate chain isn't available, or when trusting a root CA just isn't appropriate. 💜-url responder_url— specify the responder URL. Both HTTP and HTTPS (SSL/TLS) URLs work here. 🌍-VAfile file— a file containing explicitly trusted responder certificates. It's equivalent to the-verify_otherand-trust_otheroptions combined. 👑-validity_period nsec,-status_age age— the tolerated time window, in seconds, for an OCSP response. So every cert status response carries anotBeforetime and an optionalnotAftertime, and ideally the current time sits between them — but bestie, that gap can literally be a few seconds long 😭. In the real world the responder's clock and the client's clock are not perfectly synced, so the check can just... fail. Which is why-validity_periodexists: it lets you set an acceptable error range in seconds, and the default is 5 minutes. 💅
And if the notAfter time is omitted from a response, that means fresh status info is available immediately. In that case the age of the notBefore field gets checked to make sure it's not older than age seconds. By default, this extra check does not happen at all. 🫶
-verify_other file— a file stuffed with extra certificates to search through when you're trying to find the certificate that signed the OCSP response. Some responders are shady and omit the actual signer's cert from the response, so this is how you hand it over yourself. 💖
The options for the OCSP server are as follows, and yes they're a whole different vibe:
-CA file— the CA certificate that corresponds to the revocation info in indexfile.-ignore_err— ignore the invalid response. 🙈-index indexfile— indexfile is a text index file incaformat holding certificate revocation information.
Big deal alert 🔥: if this option is specified, ocsp is in responder mode, otherwise it's in client mode. The requests the responder handles can be specified on the command line (via the -issuer and -serial options), dropped in a file (via the -respin option), or come in from external OCSP clients (if port or url is specified).
And if this option is present, then -CA and -rsigner must also be present. No negotiating on that one.
-nmin minutes,-ndays days— how many minutes or days fresh revocation information is available for: this feeds thenextUpdatefield. If neither option is given, thenextUpdatefield is omitted entirely, meaning fresh revocation info is available right away. ✨-nrequest number— dip out after receiving number requests (default is unlimited, so it'll just keep going forever like a group chat at 2am).-port portnum— the port to listen for OCSP requests on. Can also be set with the-urloption.-resp_key_id— identify the signer certificate using the key ID; the default is to use the subject name.-resp_no_certs— don't include any certificates in the OCSP response.-rkey file— the private key to sign OCSP responses with; if it's not present, the file given in the-rsigneroption gets used instead.-rother file— extra certificates to include in the OCSP response.-rsigner file— the certificate to sign OCSP responses with.
Okay so here's how the verification actually goes down, step by step, no cap 🧚:
First, the OCSP responder certificate is located and the signature on the OCSP request is checked using the responder certificate's public key. Then a normal certificate verify runs on the OCSP responder certificate, building up a certificate chain along the way. Where are the trusted certs for that chain found? Either you point at them with the -CAfile and -CApath options, or they get looked for in the standard openssl certificates directory.
If that initial verify fails, the OCSP verify process halts with an error. Done. 💀
Otherwise, the issuing CA certificate in the request gets compared to the OCSP responder certificate: if they match, the OCSP verify succeeds. Slay. ✅
Otherwise, the OCSP responder certificate's CA is checked against the issuing CA certificate in the request. If those match and the OCSPSigning extended key usage is present in the OCSP responder certificate, then the OCSP verify succeeds. ✨
Otherwise, the root CA of the OCSP responder's CA is checked to see if it's trusted for OCSP signing. If it is, the OCSP verify succeeds. 👑
And if none of these checks works out, the OCSP verify fails. What all of this effectively means is: if the OCSP responder certificate is authorised directly by the CA it's issuing revocation information about (and it's correctly configured, obviously), then verification will succeed.
If the OCSP responder is a global responder — one that can give details about multiple CAs and has its own separate certificate chain — then its root CA can be trusted for OCSP signing. Or, alternatively, the responder certificate itself can be explicitly trusted with the -VAfile option. 💜
🎀 PASSWD 🎀
openssl passwd [-1 | -apr1 | -crypt] [-in file] [-noverify] [-quiet]
[-reverse] [-salt string] [-stdin] [-table] [password]
The passwd command computes the hash of a password. That's it, that's the whole gig. 🍓
The options are as follows:
-1— use the MD5 based BSD password algorithm"1".-apr1— use the"apr1"algorithm (Apache variant of the BSD algorithm).-crypt— use the"crypt"algorithm (this is the default).-in file— read passwords from file.-noverify— don't verify when reading a password from the terminal.-quiet— don't output warnings when passwords given on the command line are truncated.-reverse— switch table columns. This only makes sense in conjunction with the-tableoption.-salt string— use the salt specified by string. When reading a password from the terminal, this implies-noverify. 🧂-stdin— read passwords from standard input.-table— in the output list, prepend the cleartext password and aTABcharacter to each password hash.
🌈 PKCS7 🌈
openssl pkcs7 [-in file] [-inform der | pem] [-noout] [-out file]
[-outform der | pem] [-print] [-print_certs] [-text]
The pkcs7 command processes PKCS#7 files in DER or PEM format. Heads up though: the PKCS#7 routines only understand PKCS#7 v 1.5 as specified in RFC 2315. So don't come at it with anything fancier. 😭
The options are as follows:
-in file— the input file to read from, or standard input if not specified.-inform der | pem— the input format.-noout— don't output the encoded version of the PKCS#7 structure (or certificates if-print_certsis set).-out file— the output to write to, or standard output if not specified.-outform der | pem— the output format.-print— print the ASN.1 representation of PKCS#7 structure.-print_certs— print any certificates or CRLs contained in the file, preceded by their subject and issuer names in a one-line format.-text— print certificate details in full rather than just subject and issuer names.
🦋 PKCS8 🦋
openssl pkcs8 [-in file] [-inform der | pem] [-nocrypt] [-noiter]
[-out file] [-outform der | pem] [-passin arg]
[-passout arg] [-topk8] [-v1 alg] [-v2 alg]
The pkcs8 command processes private keys (both encrypted and unencrypted) in PKCS#8 format with a whole menu of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms. Very versatile, we love her. 💅
The options are as follows:
-in file— the input file to read from, or standard input if not specified. If the key is encrypted, a pass phrase will be prompted for. 🔑-inform der | pem— the input format.-nocrypt— generate an unencryptedPrivateKeyInfostructure. This option does not encrypt private keys at all and should only be used when absolutely necessary. Like, seriously. 😬-noiter— use an iteration count of1. See the “PKCS12” section below for a detailed explanation of this option.-out file— the output file to write to, or standard output if none is specified. If any encryption options are set, a pass phrase will be prompted for.-outform der | pem— the output format.-passin arg— the key password source.-passout arg— the output file password source.-topk8— read a traditional format private key and write a PKCS#8 format key.-v1 alg— specify a PKCS#5 v1.5 or PKCS#12 algorithm to use. The lineup:PBE-MD5-DES— 56-bit DES.PBE-SHA1-RC2-64|PBE-MD5-RC2-64|PBE-SHA1-DES— 64-bit RC2 or 56-bit DES.PBE-SHA1-RC4-128|PBE-SHA1-RC4-40|PBE-SHA1-3DESPBE-SHA1-2DES|PBE-SHA1-RC2-128|PBE-SHA1-RC2-40— PKCS#12 password-based encryption algorithm, which allow strong encryption algorithms like triple DES or 128-bit RC2. 🔥
-v2 alg— use PKCS#5 v2.0 algorithms. These are block ciphers used in CBC mode. The default isAES-256-CBC. With the exception of AES, the choices available in RFC 8018 are considered decrepit 💀 — they can be enabled withdes,des3, andrc2(rc5is no longer supported).
🎀 PKCS12 🎀
openssl pkcs12 [-aes128 | -aes192 | -aes256 | -camellia128 |
-camellia192 | -camellia256 | -des | -des3 | -idea]
[-cacerts] [-CAfile file] [-caname name]
[-CApath directory] [-certfile file] [-certpbe alg]
[-chain] [-clcerts] [-descert] [-export] [-in file]
[-info] [-inkey file] [-keyex] [-keypbe alg] [-keysig]
[-macalg alg] [-maciter] [-name name] [-nocerts]
[-nodes] [-noiter] [-nokeys] [-nomac] [-nomaciter]
[-nomacver] [-noout] [-out file] [-passin arg]
[-passout arg] [-password arg] [-twopass]
okay so the pkcs12 command is your whole bestie for PKCS#12 files (and yeah, people also call them PFX files, same thing, iykyk). Two modes, and the default one is parsing — like, if you just run it, it's reading a PKCS#12 file, no cap. Wanna make one instead? That's what -export is for. 💅
🌸 Options for parsing a PKCS12 file 🌸
-aes128|-aes192|-aes256|-camellia128|-camellia192|-camellia256|-des|-des3|-idea— encrypt the private keys using AES, CAMELLIA, DES, triple DES or the IDEA ciphers, respectively. The default is triple DES. periodt.-cacerts— only output CA certificates (not client certificates). exclusive much? 💅-clcerts— only output client certificates (not CA certificates). the other half of that duo 🫶-infile — the input file to read from, or standard input if you don't specify one.-info— output extra info about the PKCS#12 file structure, the algorithms used, and the iteration counts. it's giving receipts ✨-nocerts— do not output certificates.-nodes— do not encrypt private keys. no encryption, we die like women 😭-nokeys— do not output private keys.-nomacver— do not attempt to verify the integrity MAC before reading the file.-noout— do not output the keys and certificates to the output file version of the PKCS#12 file.-outfile — the output file to write to, or standard output if you don't specify one.-passinarg — the key password source.-passoutarg — the output file password source.-twopass— prompt for a separate integrity password and encryption password. > bestie be careful: most software always assumes these are the same, so this option will render such PKCS#12 files unreadable. you've been warned 💀
🦋 Options for PKCS12 file creation 🦋
-CAfilefile — CA storage as a file.-CApathdirectory — CA storage as a directory. The directory must be a standard certificate directory: that is, a hash of each subject name (usingx509 -hash) should be linked to each certificate. hashing girlbossery fr fr-canamename — specify the "friendly name" for other certificates. May be used multiple times to specify names for all certificates in the order they appear. yes you can spam it 💖-certfilefile — a file to read additional certificates from.-certpbealg,-keypbealg — specify the algorithm used to encrypt the private key and certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name can be used. If a cipher name (as output by thelist-cipher-algorithmscommand) is specified then it is used with PKCS#5 v2.0. For interoperability reasons it is advisable to only use PKCS#12 algorithms. like, technically you can do other stuff, but the vibes are better if you don't 🙈-chain— include the entire certificate chain of the user certificate. The standard CA store is used for this search. If the search fails, it is considered a fatal error. no pressure or anything 😭-descert— encrypt the certificate using triple DES; this may render the PKCS#12 file unreadable by some "export grade" software. By default, the private key is encrypted using triple DES and the certificate using 40-bit RC2. > yeah so 40-bit RC2 is the default for certs, and flipping to-descertmakes some crusty "export grade" software unable to read it. dramatic but true 💅-export— create a PKCS#12 file (rather than parsing one). the main character option, lowkey 👑-infile — the input file to read from, or standard input if not specified. The order doesn't matter but one private key and its corresponding certificate should be present. If additional certificates are present, they will also be included in the PKCS#12 file.-inkeyfile — file to read a private key from. If not present, a private key must be present in the input file.-keyex|-keysig— specify whether the private key is to be used for key exchange or just signing. Normally, "export grade" software will only allow 512-bit RSA keys to be used for encryption purposes, but arbitrary length keys for signing. The-keysigoption marks the key for signing only. Signing only keys can be used for S/MIME signing, authenticode (ActiveX control signing) and SSL client authentication. so many little jobs, such a multitasker ✨-macalgalg — specify the MAC digest algorithm. The default is SHA1.-maciter— included for compatibility only: it used to be needed to use MAC iterations counts but they are now used by default. a lil legacy relic, we keep it around for the culture 🎀-namename — specify the "friendly name" for the certificate and private key. This name is typically displayed in list boxes by software importing the file. give it a cute name, it deserves one 🥺-nomac— don't attempt to provide the MAC integrity.-nomaciter,-noiter— affect the iteration counts on the MAC and key algorithms.
okay so here's the lore: to discourage attacks by using large dictionaries of common passwords, the algorithm that derives keys from passwords can have an iteration count applied to it — this causes a certain part of the algorithm to be repeated and slows it down. The MAC is used to check the file integrity, but since it will normally have the same password as the keys and certificates, it could also be attacked. By default, both MAC and encryption iteration counts are set to 2048; using these options the MAC and encryption iteration counts can be set to 1. Since this reduces the file security, you should not use these options unless you really have to. Most software supports both MAC and key iteration counts.
fr fr do NOT casually set this to 1, it's like leaving your front door open because the lock was mildly annoying 😭
-outfile — the output file to write to, or standard output if not specified.-passinarg — the key password source.-passoutarg — the output file password source.-passwordarg — with-export,-passwordis equivalent to-passout. Otherwise,-passwordis equivalent to-passin. it's a shapeshifter, it just matches the energy of whatever mode you're in 💫
✨ PKEY ✨
openssl pkey [cipher] [-in file] [-inform der | pem] [-noout]
[-out file] [-outform der | pem] [-passin arg]
[-passout arg] [-pubin] [-pubout] [-text] [-text_pub]
The pkey command processes public or private keys. They can be converted between various forms and their components printed out. little glow-up station for your keys 💅
🍓 Options 🍓
- cipher — encrypt the private key with the specified cipher. Any algorithm name accepted by
EVP_get_cipherbyname(3)is acceptable, such asdes3. -infile — the input file to read from, or standard input if not specified. If the key is encrypted, a pass phrase will be prompted for.-inform der | pem— the input format.-noout— do not output the encoded version of the key.-outfile — the output file to write to, or standard output if not specified. If any encryption options are set then a pass phrase will be prompted for.-outform der | pem— the output format.-passinarg — the key password source.-passoutarg — the output file password source.-pubin— read in a public key, not a private key.-pubout— output a public key, not a private key. Automatically set if the input is a public key. it's automatic, she knows what she's doing 💖-text— print the public/private key in plain text.-text_pub— print out only public key components even if a private key is being processed. keeping the private bits private, we love a boundaries queen 🙌
🌈 PKEYPARAM 🌈
openssl pkeyparam [-in file] [-noout] [-out file] [-text]
The pkeyparam command processes public or private keys. The key type is determined by the PEM headers. she reads the headers and just knows, no explanation needed ✨
⭐ Options ⭐
-infile — the input file to read from, or standard input if not specified.-noout— do not output the encoded version of the parameters.-outfile — the output file to write to, or standard output if not specified.-text— print the parameters in plain text.
💅 PKEYUTL 💅
openssl pkeyutl [-asn1parse] [-certin] [-decrypt] [-derive] [-encrypt]
[-hexdump] [-in file] [-inkey file]
[-keyform der | pem] [-out file] [-passin arg]
[-peerform der | pem] [-peerkey file]
[-pkeyopt opt:value] [-pubin] [-rev] [-sigfile file]
[-sign] [-verify] [-verifyrecover]
okay so pkeyutl is the lil multitool of public key operations — you can do them with, like, any supported algorithm 🦋. she's flexible like that.
Here's the options, bestie:
-asn1parse— ASN.1-parses the output data ✨. super handy when you pair it with-verifyrecoverand there's an ASN.1 structure sitting in the signature.-certin— heads up, the input is a certificate that's holding a public key 🎀.-decrypt— decrypt the input data with a private key 🔐.-derive— derive a shared secret using the peer key 🤝.-encrypt— encrypt the input data with a public key 🔒.-hexdump— hex dump the output data 💀 (yes, the whole thing).-in file— the input file you're reading from. if you don't say, it's standard input 📥.-inkey file— the input key file. by default it should be a private key 🗝️.-keyform der | pem— the key format.-out file— the output file to write to, or standard output if you don't specify 📤.-passin arg— the key password source.-peerform der | pem— the peer key format.-peerkey file— the peer key file, used by key derivation (agreement) operations 🫶.-pkeyopt opt:value— sets the public key algorithm option opt to value. Unless it says otherwise somewhere, every algorithm supports the formatdigest:alg, which picks the digest forsign,verify, andverifyrecoveroperations. the value alg should be a digest name like the ones used in theEVP_get_digestbyname(3)function 🌸.
The RSA algorithm supports the encrypt, decrypt, sign, verify, and verifyrecover operations in general. Some padding modes only support some of these operations however 👀.
rsa_padding_mode:mode— sets the RSA padding mode. acceptable values for mode arepkcs1for PKCS#1 padding;nonefor no padding;oaepfor OAEP mode;x931for X9.31 mode; andpssfor PSS.
In PKCS#1 padding, if the message digest isn't set then the supplied data is signed or verified directly instead of using a DigestInfo structure. If a digest is set then a DigestInfo structure is used and its length must correspond to the digest type. For oeap mode only encryption and decryption is supported (yep, that's how it's spelled in the docs, bestie 🙈). For x931, if the digest type is set it's used to format the block data; otherwise the first byte is used to specify the X9.31 digest ID. Sign, verify, and verifyrecover can be performed in this mode. For pss mode only sign and verify are supported and the digest type must be specified — no cap, that one's mandatory 💅.
rsa_pss_saltlen:len— forpssmode only, this option specifies the salt length. two special values are supported:-1sets the salt length to the digest length. When signing,-2sets the salt length to the maximum permissible value. When verifying,-2causes the salt length to be automatically determined based on the PSS block structure ⭐.
The DSA algorithm supports the sign and verify operations. Currently there are no additional options other than digest. Only the SHA1 digest can be used and this digest is assumed by default 🎀.
The DH algorithm supports the derive operation and no additional options 🤷♀️.
The EC algorithm supports the sign, verify, and derive operations. The sign and verify operations use ECDSA and derive uses ECDH. Currently there are no additional options other than digest. Only the SHA1 digest can be used and this digest is assumed by default 🌈.
-pubin— the input file is a public key 🔑.-rev— reverse the order of the input buffer 🔄.-sigfile file— signature file (verify operation only) ✍️.-sign— sign the input data and output the signed result. this one requires a private key 🗝️✨.-verify— verify the input data against the signature file and indicate if the verification succeeded or failed ✅❌.-verifyrecover— verify the input data and output the recovered data 🧚.
🔢 PRIME 🔢
openssl prime [-bits n] [-checks n] [-generate] [-hex] [-safe] p
The prime command is here to generate prime numbers, or to check numbers for primality 🔥. Results are probabilistic: they have an exceedingly high likelihood of being correct, but they are not guaranteed 💀 — keep that in mind, okay?
The options are as follows:
-bits n— specify the number of bits in the generated prime number. must be used together with-generate🫶.-checks n— perform a Miller-Rabin probabilistic primality test with n iterations. the default is20✨.-generate— generate a pseudo-random prime number. must be used together with-bits🎲.-hex— output in hex format 🧮.-safe— generate only "safe" prime numbers (i.e. a prime p so that (p-1)/2 is also prime) 👑.- p — test if number p is prime 🔍.
🎲 RAND 🎲
openssl rand [-base64] [-hex] [-out file] num
The rand command outputs num pseudo-random bytes 🌸. that's it, that's the whole gig.
The options are as follows:
-base64— perform base64 encoding on the output 🎀.-hex— specify hexadecimal output 💜.-out file— the output file to write to, or standard output if not specified 📤.
📜 REQ 📜
openssl req [-addext ext] [-batch] [-config file] [-days n]
[-extensions section] [-in file] [-inform der | pem]
[-key keyfile] [-keyform der | pem] [-keyout file]
[-md4 | -md5 | -sha1] [-modulus] [-multivalue-rdn]
[-nameopt option] [-new] [-newhdr] [-newkey arg] [-nodes]
[-noout] [-out file] [-outform der | pem] [-passin arg]
[-passout arg] [-pkeyopt opt:value] [-pubkey]
[-reqexts section] [-reqopt option] [-set_serial n]
[-sigopt nm:v] [-subj arg] [-subject] [-text] [-utf8]
[-verbose] [-verify] [-x509]
okay so req is the main character for creating and processing certificate requests in PKCS#10 format 👑. and bestie, she can also create self-signed certificates — you know, for use as root CAs and stuff. versatile icon 💅✨.
The options are as follows:
-addext ext— add a specific extension to the certificate (if the-x509option is present) or to the certificate request. the argument has to have the form of akey=valuepair, exactly like it'd appear in a config file. you can give this option multiple times 🎀.-batch— non-interactive mode 🤖.-config file— specify an alternative configuration file 📂.-days n— specify the number of days to certify the certificate for. the default is30days. used with the-x509option 📅.-extensions section,-reqexts section— specify alternative sections to include certificate extensions (with-x509) or certificate request extensions, which lets you use several different sections in the same configuration file 🗂️.-in file— the input file to read a request from, or standard input if not specified. a request is only read if the creation options-newand-newkeyare not specified 👀.-inform der | pem— the input format.-key keyfile— the file to read the private key from. it also accepts PKCS#8 format private keys for PEM format files 🗝️.-keyform der | pem— the format of the private key file specified in the-keyargument. the default ispem✨.-keyout file— the file to write the newly created private key to. if you don't specify this option, the filename present in the configuration file is used 📝.-md5 | -sha1 | -sha256— the message digest to sign the request with. this overrides the digest algorithm specified in the configuration file.
Some public key algorithms may override this choice. For instance, DSA signatures always use SHA1 💀 (not up for discussion, apparently).
-modulus— print the value of the modulus of the public key contained in the request 🧮.-multivalue-rdn— this option causes the-subjargument to be interpreted with full support for multivalued RDNs, for example"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe". if-multivalue-rdnis not used, the UID value is set to"123456+CN=John Doe"🙈.-nameopt option,-reqopt option— determine how the subject or issuer names are displayed. option can be a single option or multiple options separated by commas. alternatively, these options may be used more than once to set multiple options. see the “X509” section below for details 👑.-new— generate a new certificate request. the user gets prompted for the relevant field values 📝. the actual fields prompted for, plus their maximum and minimum sizes, are specified in the configuration file and any requested extensions.
If the -key option isn't used, it'll generate a new RSA private key using information specified in the configuration file 🔑✨.
-newhdr— add the wordNEWto the PEM file header and footer lines on the outputted request. some software and CAs need this 🎀.-newkey arg— create a new certificate request and a new private key. the argument takes one of several forms 🦋.
rsa:nbits generates an RSA key nbits in size. if nbits is omitted, the default key size is used.
dsa:file generates a DSA key using the parameters in file.
param:file generates a key using the parameters or certificate in file.
All other algorithms support the form algorithm:file, where file may be an algorithm parameter file, created by the genpkey -genparam command, or an X.509 certificate for a key with the appropriate algorithm. file can be omitted, in which case any parameters can be specified via the -pkeyopt option 💅.
-nodes— do not encrypt the private key 🙈.-noout— do not output the encoded version of the request 🚫.-out file— the output file to write to, or standard output if not specified 📤.-outform der | pem— the output format, bestie. pick one 💅-passin arg— where the key password comes from 🔑-passout arg— where the output file password comes from 🔒-pkeyopt opt:value— sets the public key algorithm optionopttovalue✨-pubkey— output the public key, not the whole thing 🗝️-reqopt option— customises the output format used with-text. the option argument can be a single option or multiple options separated by commas. also go peek at the discussion of-certoptin thex509command, iykyk 🎀-set_serial n— the serial number to use when outputting a self-signed certificate. you can give it as a decimal value, or as hex if you put0xin front. and yeah, negative serial numbers are technically possible but not recommended — don't do it, fr fr 🙈-sigopt nm:v— passes options to the signature algorithm during the sign operation. the names and values of these options are algorithm-specific, so like, no universal cheat sheet 🌸-subj arg— replaces the subject field of an input request with the specified data and outputs the modified request. arg must be formatted as/type0=value0/type1=value1/type2=...; characters may be escaped by\(backslash); no spaces are skipped. lowkey picky about that 💀-subject— print the request subject (or the certificate subject if-x509is specified) 👑-text— print the certificate request in plain text 📝-utf8— interpret field values as UTF8 strings, not ASCII 🌈-verbose— print extra details about the operations being performed, for the girlies who need the full commentary 🫶-verify— verify the signature on the request ✅-x509— output a self-signed certificate instead of a certificate request. this is typically used to generate a test certificate or a self-signed root CA. the extensions added to the certificate (if any) are specified in the configuration file. unless specified using the-set_serialoption,0is used for the serial number ⭐
🧚 the req config section 🧚
The configuration options are specified in the "req" section of the configuration file. the options available are as follows, bestie:
attributes— the section containing any request attributes; its format is the same asdistinguished_name. typically these may contain thechallengePasswordorunstructuredNametypes. they are currently ignored by the openssl request signing utilities, but some CAs might want them. so like, they're there, being ignored, main character energy of a wallflower 😭default_bits— the default key size, in bits. the default is2048. it's used if the-newoption is used, and can be overridden by using the-newkeyoption 📏default_keyfile— the default file to write a private key to, or standard output if not specified. it can be overridden by the-keyoutoption 📁default_md— the digest algorithm to use. possible values includemd5,sha1andsha256(the default). it can be overridden on the command line 🔐distinguished_name— the section containing the distinguished name fields to prompt for when generating a certificate or certificate request. the format is described below 👇encrypt_key— if set to"no"and a private key is generated, it is not encrypted. it's equivalent to the-nodesoption. for compatibility,encrypt_rsa_keyis an equivalent option 🗝️input_password|output_password— the passwords for the input private key file (if present) and the output private key file (if one will be created). the command line options-passinand-passoutoverride the configuration file values 🔑oid_file— a file containing additional OBJECT IDENTIFIERS. each line of the file should consist of the numerical form of the object identifier, followed by whitespace, then the short name followed by whitespace and finally the long name 🌟oid_section— specify a section in the configuration file containing extra object identifiers. each line should consist of the short name of the object identifier followed by=and the numerical form. the short and long names are the same when this option is used ✨prompt— if set to"no", it disables prompting of certificate fields and just takes values from the config file directly. it also changes the expected format of thedistinguished_nameandattributessections 🙅♀️req_extensions— the configuration file section containing a list of extensions to add to the certificate request. it can be overridden by the-reqextsoption 🎀string_mask— limit the string types for encoding certain fields. the following values may be used, limiting strings to the indicated types:utf8only—UTF8String. this is the default, as recommended by PKIX in RFC 2459 💖default—PrintableString,IA5String,T61String,BMPString,UTF8String🌸pkix—PrintableString,IA5String,BMPString,UTF8String. inspired by the PKIX recommendation in RFC 2459 for certificates generated before 2004, but differs by also permittingIA5String🦋nombstr—PrintableString,IA5String,T61String,UniversalString. a workaround for some ancient software that had problems with the variable-sizedBMPStringandUTF8Stringtypes 💀MASK:number— an explicit bitmask of permitted types, where number is a C-style hex, decimal, or octal number that's a bit-wise OR ofB_ASN1_*values from<openssl/asn1.h>🧮
utf8— if set to"yes", field values are interpreted as UTF8 strings 🌈x509_extensions— the configuration file section containing a list of extensions to add to a certificate generated when the-x509switch is used. it can be overridden by the-extensionscommand line switch 👑
🌸 the two DN/attribute formats 🌸
There are two separate formats for the distinguished name and attribute sections. if the -prompt option is set to "no", then these sections just consist of field names and values. if the -prompt option is absent or not set to "no", then the file contains field prompting information of the form:
fieldName="prompt"
fieldName_default="default field value"
fieldName_min= 2
fieldName_max= 4
"fieldName" is the field name being used, for example commonName (or CN). the "prompt" string is used to ask the user to enter the relevant details. if the user enters nothing, the default value is used; if no default value is present, the field is omitted. a field can still be omitted if a default value is present, if the user just enters the . character 🫶
The number of characters entered must be between the fieldName_min and fieldName_max limits: there may be additional restrictions based on the field being used (for example countryName can only ever be two characters long and must fit in a PrintableString). so like, don't try to be creative there 😭
Some fields (such as organizationName) can be used more than once in a DN. this presents a problem because configuration files will not recognize the same name occurring twice. to avoid this problem, if the fieldName contains some characters followed by a full stop, they will be ignored. so, for example, a second organizationName can be input by calling it "1.organizationName" — iconic workaround, no cap 💅
The actual permitted field names are any object identifier short or long names. these are compiled into openssl and include the usual values such as commonName, countryName, localityName, organizationName, organizationalUnitName, stateOrProvinceName. additionally, emailAddress is included as well as name, surname, givenName, initials and dnQualifier 🌟
Additional object identifiers can be defined with the oid_file or oid_section options in the configuration file. any additional fields will be treated as though they were a DirectoryString ✨
💜 RSA 💜
openssl rsa [-aes128 | -aes192 | -aes256 | -des | -des3] [-check]
[-in file] [-inform der | net | pem | pvk] [-modulus]
[-noout] [-out file] [-outform der | net | pem | pvk]
[-passin arg] [-passout arg] [-pubin] [-pubout]
[-pvk-none | -pvk-strong | -pvk-weak] [-RSAPublicKey_in]
[-RSAPublicKey_out] [-text]
The rsa command processes RSA keys. they can be converted between various forms and their components printed out. rsa uses the traditional SSLeay compatible format for private key encryption: newer applications should use the more secure PKCS#8 format using the pkcs8 utility. okay so that's the tea — old format works but the glow-up is PKCS#8 ☕✨
The options are as follows:
-aes128|-aes192|-aes256|-des|-des3— encrypt the private key with the AES, DES, or the triple DES ciphers, respectively, before outputting it. a pass phrase is prompted for. if none of these options are specified, the key is written in plain text. this means that using thersautility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or by setting the encryption options it can be used to add or change the pass phrase. these options can only be used with PEM format output files 🔐-check— check the consistency of an RSA private key ✅-in file— the input file to read from, or standard input if not specified. if the key is encrypted, a pass phrase will be prompted for 📥-inform der | net | pem | pvk— the input format 🎀-noout— do not output the encoded version of the key 🙅♀️-modulus— print the value of the modulus of the key 🧮-out file— the output file to write to, or standard output if not specified 📤-outform der | net | pem | pvk— the output format 🌸-passin arg— the key password source 🔑-passout arg— the output file password source 🔒-pubin— read in a public key, not a private key 🗝️-pubout— output a public key, not a private key. automatically set if the input is a public key ✨-pvk-none|-pvk-strong|-pvk-weak— enable or disable PVK encoding. the default is-pvk-strong💪-RSAPublicKey_in,-RSAPublicKey_out— same as-pubinand-puboutexceptRSAPublicKeyformat is used instead 🦋-text— print the public/private key components in plain text 📝
✨ RSAUTL ✨
openssl rsautl [-asn1parse] [-certin] [-decrypt] [-encrypt] [-hexdump]
[-in file] [-inkey file] [-keyform der | pem]
[-oaep | -pkcs | -raw | -x931] [-out file] [-passin arg]
[-pubin] [-rev] [-sign] [-verify]
Okay so rsautl is the RSA multitool bestie — it signs, verifies, encrypts and decrypts data using the RSA algorithm. That's literally the whole personality. 💅
The options are as follows:
-asn1parse— ASN.1-parse the output data. Super useful when you pair it with-verify, iykyk. 🔍-certin— tells it the input is a certificate that has an RSA public key hiding inside. 🎀-decrypt— decrypt the input data using an RSA private key.-encrypt— encrypt the input data using an RSA public key.-hexdump— hex dump the output data. For the girlys who need to see the bytes. 💀-in file— the input to read from. If you don't specify it, it takes standard input.-inkey file— the input key file. By default that means an RSA private key.-keyform der | pem— the private key format. Default ispem, no surprises.-oaep | -pkcs | -raw | -x931— the padding. Respectively that's PKCS#1 OAEP, PKCS#1 v1.5 (this one's the default 💫), no padding at all, or ANSI X9.31. For signatures though? Only-pkcsand-rawcan be used. Noted. ✍️-out file— the output file to write to, or standard output if you don't specify one.-passin arg— the key password source.-pubin— the input file is an RSA public key.-rev— reverse the order of the input buffer. Just. Flipped. 🙃-sign— sign the input data and output the signed result. This one requires an RSA private key, so like, bring the right one.-verify— verify the input data and output the recovered data.
🌸 S_CLIENT 🌸
openssl s_client [-4 | -6] [-alpn protocols] [-bugs] [-CAfile file]
[-CApath directory] [-cert file] [-certform der | pem]
[-check_ss_sig] [-cipher cipherlist]
[-connect host[:port]] [-crl_check] [-crl_check_all]
[-crlf] [-debug] [-dtls] [-dtls1_2] [-extended_crl]
[-groups list] [-host host] [-ign_eof]
[-ignore_critical] [-issuer_checks] [-key keyfile]
[-keyform der | pem] [-keymatexport label]
[-keymatexportlen len] [-legacy_server_connect] [-msg]
[-mtu mtu] [-nbio] [-nbio_test] [-no_comp]
[-no_ign_eof] [-no_legacy_server_connect] [-no_ticket]
[-no_tls1_2] [-no_tls1_3] [-pass arg] [-policy_check]
[-port port] [-prexit] [-proxy host:port] [-quiet]
[-reconnect] [-servername name] [-serverpref]
[-sess_in file] [-sess_out file] [-showcerts]
[-starttls protocol] [-state] [-status] [-timeout]
[-tls1_2] [-tls1_3] [-tlsextdebug]
[-use_srtp profiles] [-verify depth]
[-verify_return_error] [-x509_strict] [-xmpphost host]
So s_client is the generic SSL/TLS client — it connects out to a remote host using SSL/TLS. Generic queen behavior. 👑
Once a connection is established with an SSL server, anything the server sends gets displayed, and any key presses you make get sent to the server. When you're using it interactively (which means neither -quiet nor -ign_eof was given), the session gets renegotiated if the line begins with an R. If the line begins with a Q, or if end of file is reached, the connection gets closed down. Periodt. 💅
The options are as follows:
-4— attempt connections using IPv4 only.-6— attempt connections using IPv6 only.-alpn protocols— enable Application-Layer Protocol Negotiation. protocols is a comma-separated list of protocol names that the client should advertise support for. 🦋-bugs— enable various workarounds for buggy implementations. Gotta be nice to the buggy ones. 🫶-CAfile file— a file containing trusted certificates, used during server authentication and also when it's trying to build the client certificate chain.-CApath directory— the directory to use for server certificate verification. This directory must be in "hash format" — see-verifyfor the deets. These are also used when building the client certificate chain.-cert file— the certificate to use, if one is requested by the server. Default is to not use a certificate at all.-certform der | pem— the certificate format. Default ispem.-check_ss_sig,-crl_check,-crl_check_all,-extended_crl,-ignore_critical,-issuer_checks,-policy_check,-x509_strict— set various certificate chain validation options. See theverifycommand for all the details, bestie, it's a whole thing. 🔍-cipher cipherlist— modify the cipher list the client sends. Even though the server decides which cipher suite actually gets used, it should take the first supported cipher in the list the client sent. See thecipherscommand for more. 🔐-connect host[:port]— the host and port to connect to. If you don't specify, it tries to connect to the local host on port4433. Alternatively the host and port pair can be separated with a forward-slash character, which is handy for numeric IPv6 addresses.-crlf— translate a line feed from the terminal into CR+LF, as some servers require. ✨-debug— print extensive debugging information, including a hex dump of all traffic. Full nosy mode. 💀-dtls— permit any version of DTLS.-dtls1_2— permit only DTLS1.2.-groups list— set the supported elliptic curve groups to the colon separated list of group NIDs or names as documented inSSL_CTX_set1_groups_list(3).-host host— the host to connect to. Default islocalhost.-ign_eof— inhibit shutting down the connection when end of file is reached in the input.-key keyfile— the private key to use. If you don't specify one, the certificate file gets used.-keyform der | pem— the private key format. Default ispem.-keymatexport label— export keying material using label.-keymatexportlen len— export len bytes of keying material (default20).-legacy_server_connect,-no_legacy_server_connect— allow or disallow the initial connection to servers that don't support RI.-msg— show all protocol messages with hex dump.-mtu mtu— set the link layer MTU.-nbio— turn on non-blocking I/O.-nbio_test— test non-blocking I/O.-no_ign_eof— shut down the connection when end of file is reached in the input. Can be used to override the implicit-ign_eofthat comes after-quiet.-no_tls1_2|-no_tls1_3— disable the use of TLS1.2 and 1.3, respectively.-no_ticket— disable RFC 4507 session ticket support.-pass arg— the private key password source.-port port— the port to connect to. Default is4433.-prexit— print session information when the program exits. This will always attempt to print out information even if the connection fails. Normally, information only gets printed out once, and only if the connection succeeds. This option is useful because the cipher in use may be renegotiated, or the connection may fail because a client certificate is required, or is requested only after an attempt is made to access a certain URL. > Heads up though: the output produced by this option is not always accurate, because a connection might never have been established. 😭-proxy host:port— use the HTTP proxy at host and port. The connection to the proxy is done in cleartext and the-connectargument is given to the proxy. If not specified,localhostis used as the final destination. After that, switch the connection through the proxy to the destination to TLS.-quiet— inhibit printing of session and certificate information. This implicitly turns on-ign_eoftoo.-reconnect— reconnect to the same server5times using the same session ID; this can be used as a test that session caching is working. 🔁-servername name— include the TLS Server Name Indication (SNI) extension in theClientHellomessage, using the specified server name.-showcerts— display the whole server certificate chain. Normally only the server certificate itself gets displayed.-serverpref— use the server's cipher preferences.-sess_in file— load TLS session from file. The client will attempt to resume a connection from this session.-sess_out file— output TLS session to file.-starttls protocol— send the protocol-specific messages to switch to TLS for communication. protocol is a keyword for the intended protocol. Currently the supported keywords areftp,imap,sieve,smtp,pop3, andxmpp. 🌈-state— print the SSL session states.-status— send a certificate status request to the server (OCSP stapling). The server response (if any) gets printed out.-timeout— enable send/receive timeout on DTLS connections.-tls1_2|-tls1_3— permit only TLS1.2 or 1.3 respectively.-tlsextdebug— print a hex dump of any TLS extensions received from the server.-use_srtp profiles— offer SRTP key management with a colon-separated profile list.-verify depth— turn on server certificate verification, with a maximum length of depth. Currently the verify operation continues after errors so all the problems with a certificate chain can be seen. > Side effect time: because of that, the connection will never fail due to a server certificate verify failure. 🙈-verify_return_error— return verification error.-xmpphost hostname— when used with-starttls xmpp, specify the host for the"to"attribute of the stream element. If this option isn't specified, then the host specified with-connectgets used.
💅 S_SERVER 💅
okay so picture this: openssl s_server is literally the generic SSL/TLS server bestie. it sits there and listens for connections on a port and does SSL/TLS. that's the whole vibe. 🎀
Here's the whole synopsis, and yes it's a lot, we're not skipping a single flag:
openssl s_server [-accept port] [-alpn protocols] [-bugs]
[-CAfile file] [-CApath directory] [-cert file]
[-cert2 file] [-certform der | pem]
[-cipher cipherlist] [-context id] [-crl_check]
[-crl_check_all] [-crlf] [-dcert file]
[-dcertform der | pem] [-debug] [-dhparam file]
[-dkey file] [-dkeyform der | pem] [-dpass arg]
[-dtls] [-dtls1] [-dtls1_2] [-groups list] [-HTTP]
[-id_prefix arg] [-key keyfile] [-key2 keyfile]
[-keyform der | pem] [-keymatexport label]
[-keymatexportlen len] [-msg] [-mtu mtu]
[-naccept num] [-named_curve arg] [-nbio] [-nbio_test]
[-no_cache] [-no_dhe] [-no_ecdhe] [-no_ticket]
[-no_tls1_2] [-no_tls1_3] [-no_tmp_rsa] [-nocert]
[-pass arg] [-quiet] [-servername name]
[-servername_fatal] [-serverpref] [-state] [-status]
[-status_timeout nsec] [-status_url url]
[-status_verbose] [-timeout] [-tls1_2] [-tls1_3]
[-tlsextdebug] [-use_srtp profiles] [-Verify depth]
[-verify depth] [-verify_return_error] [-WWW] [-www]
🫶 INTERACTIVE MODE, aka the fun part
ok so the way this works: if a client connects and you didn't pass -www or -WWW, then literally every byte the client sends gets displayed to you 🦋 and any key you press gets sent to the client. it's giving walkie-talkie. and a few single-letter keystrokes do extra special stuff:
P— sends plain text, which should make the client disconnect. bye bestie 👋Q— ends the current SSL connection and exits. we're done here periodt.q— ends the current SSL connection, but still accepts new connections. iconic, no quitter energy.R— renegotiates the SSL session and requests a client certificate.r— renegotiates the SSL session (no cert request this time).S— prints out some session cache status info. ✨
✨ THE OPTIONS ✨
-accept port— listens on TCPportfor connections. the default is port4433. 🍓-alpn protocols— turns on the Application-Layer Protocol Negotiation.protocolsis a comma-separated list of the protocol names you support. slay.-bugs— enables various workarounds for buggy implementations. be nice, they're trying 💀-CAfile file— a file containing the trusted certificates to use during client authentication, and also to use when trying to build the server certificate chain. the list is also used in the list of acceptable client CAs passed to the client whenever a certificate is requested. multitasking queen 👑-CApath directory— the directory to use for client certificate verification. this directory must be in "hash format" — check-verifyfor the deets. these are also used when building the server certificate chain.-cert file— the certificate to use. most of the server's cipher suites require a certificate, and some require a certificate with a certain public key type — like, the DSS cipher suites need a certificate containing a DSS (DSA) key. if you don't specify one, the fileserver.pemgets used.-cert2 file— the certificate to use for servername. 🦋-certform der | pem— the certificate format. default ispem.-cipher cipherlist— modifies the cipher list the server uses. lets you change the server's cipher list. when the client sends a list of supported ciphers, the first client cipher that's also in the server list gets used. and because the client specifies the preference order, the order of the server cipherlist is literally irrelevant. see thecipherscommand for more info.-context id— sets the SSL context ID. you can give it any string value you want. go feral 💅-crl_check,-crl_check_all— checks that the peer certificate hasn't been revoked by its CA. the CRLs are appended to the certificate file.-crl_check_allchecks all the CRLs of all the CAs in the chain. thorough queen.-crlf— translates a line feed from the terminal into CR+LF.-dcert file,-dkey file— specify an additional certificate and private key. they behave exactly like the-certand-keyoptions, except there's no default if you don't specify them (so no additional certificate or key gets used). by using RSA and DSS certificates and keys, a server can support clients that only support RSA or DSS cipher suites by using an appropriate certificate. versatile icon.-dcertform der | pem,-dkeyform der | pem,-dpass arg— additional certificate format, additional private key format, and private key password source, respectively.-debug— prints extensive debugging info, including a hex dump of all traffic. not me hex dumping everything 🙈-dhparam file— the DH parameter file to use. the ephemeral DH cipher suites generate keys using a set of DH parameters. if you don't specify this, it tries to load the parameters from the server certificate file. and if that fails, a static set of parameters hard coded into thes_serverprogram gets used. backup plan on deck.-dtls— permits any version of DTLS.-dtls1_2— permits only DTLS1.2. strict.-groups list— sets the supported elliptic curve groups to the colon-separated list of group NIDs or names, as documented inSSL_CTX_set1_groups_list(3). 🌈-HTTP— emulates a simple web server. pages are resolved relative to the current directory. so like, if the URLhttps://myhost/page.htmlis requested, the file./page.htmlgets loaded. the files loaded are assumed to contain a complete and correct HTTP response — meaning lines that are part of the HTTP response line and headers must end with CRLF. no cap.-id_prefix arg— generates SSL/TLS session IDs prefixed byarg. mostly useful for testing any SSL/TLS code that wants to deal with multiple servers, where each one might be generating a unique range of session IDs.-key keyfile— the private key to use. if you don't specify it, the certificate file gets used.-key2 keyfile— the private key to use for servername.-keyform der | pem— the private key format. default ispem.-keymatexport label— exports keying material usinglabel.-keymatexportlen len— exportslenbytes of keying material (default20).-msg— shows all protocol messages with hex dump. so much hex. 💀-mtu mtu— sets the link layer MTU.-naccept num— terminates the server afternumconnections. it has a limit bestie.-named_curve arg— specifies the elliptic curve name to use for ephemeral ECDH keys. this option is deprecated — use-groupsinstead. we've moved on 💅-nbio— turns on non-blocking I/O.-nbio_test— tests non-blocking I/O.-no_cache— disables session caching.-no_dhe— disables ephemeral DH cipher suites.-no_ecdhe— disables ephemeral ECDH cipher suites.-no_ticket— disables RFC 4507 session ticket support. 🎟️ no tickets for you-no_tls1_2 | -no_tls1_3— disables the use of TLS1.2 and 1.3, respectively.-no_tmp_rsa— disables temporary RSA key generation.-nocert— doesn't use a certificate. this restricts the available cipher suites to the anonymous ones (currently just anonymous DH). living dangerously 😭-pass arg— the private key password source.-quiet— inhibits printing of session and certificate information. shhh 🤫-servername name— sets the TLS Server Name Indication (SNI) extension withname.-servername_fatal— sends a fatal alert if the servername doesn't match. the default is a warning alert. dramatic but valid.-serverpref— uses the server's cipher preferences.-state— prints the SSL session states. 👀-status— enables certificate status request support (OCSP stapling).-status_timeout nsec— sets the timeout for the OCSP response in seconds.-status_url url— sets a fallback responder URL to use if there's no responder URL present in the server certificate. without this option, an error gets returned if the server certificate doesn't contain a responder address.-status_verbose— enables certificate status request support (OCSP stapling) and gives you a verbose printout of the OCSP response. we love details.-timeout— enables send/receive timeout on DTLS connections. ⏰-tls1_2 | -tls1_3— permits only TLS1.2, or 1.3, respectively. pick your fighter.-tlsextdebug— prints a hex dump of any TLS extensions received from the server.-use_srtp profiles— offers SRTP key management with a colon-separated profile list. 🔥-verify_return_error— returns the verification error. no sweeping it under the rug.-WWW— emulates a simple web server. pages are resolved relative to the current directory. so like, if the URLhttps://myhost/page.htmlis requested, the file./page.htmlgets loaded. that's it, that's the whole option.-www— sends a status message to the client when it connects, including info about the ciphers used and various session parameters. the output is in HTML format, so this option will normally get used with a web browser. 🌸-Verify depth,-verify depth— requests a certificate chain from the client, with a maximum length ofdepth. with-Verify, the client must supply a certificate or an error occurs; with-verify, a certificate gets requested but the client doesn't have to send one. soft launch vs hard requirement fr fr.
💅 S_TIME 💅
openssl s_time [-bugs] [-CAfile file] [-CApath directory] [-cert file]
[-cipher cipherlist] [-connect host[:port]]
[-key keyfile] [-nbio] [-new] [-no_shutdown] [-reuse]
[-time seconds] [-verify depth] [-www page]
Ok so s_time is literally the glow-up of a generic SSL/TLS client — it connects to a remote host over SSL/TLS and, get this, it times everything. ⏱️ It can request a page from the server, and the time it takes to transfer that payload data gets folded right into its timing measurements. Bestie is out here measuring the number of connections within a given timeframe, the amount of data transferred (if any!), and then it calculates the average time spent per connection. It's giving benchmark era. ✨
The options are as follows:
-bugs— turns on a bunch of workarounds for implementations that are, um, buggy 🐛.-CAfile file— a file holding trusted certificates, used during server authentication and also used when it's trying to build the client certificate chain.-CApath directory— the directory used for server certificate verification. Heads up: this directory has to be in "hash format" — go peek atverifyfor the details. These get used when building the client certificate chain too.-cert file— the certificate to use, if the server asks for one. Default behavior is to not use a certificate at all.-cipher cipherlist— changes up the cipher list the client sends. Even though the server decides which cipher suite actually gets used, it should pick the first supported cipher in the list the client sent. Check thecipherscommand for more info 👀.-connect host[:port]— the host and port you're connecting to.-key keyfile— the private key to use. If you don't specify it, the certificate file gets used instead.-nbio— flips on non-blocking I/O.-new— runs the timing test using a brand-new session ID for every single connection.-no_shutdown— shuts the connection down without sending a "close notify" shutdown alert to the server. Rude but efficient 💀.-reuse— runs the timing test using the same session ID for each connection.-time seconds— capss_timebenchmarks at that many seconds. Default is30seconds.-verify depth— turns on server certificate verification with a maximum length of depth. Ngl, right now the verify operation keeps going after errors, so you can see all the problems with a certificate chain at once. Side effect though: the connection will never fail because of a server certificate verify failure. 🙈-www page— the page to GET from the server. A value of/gets theindex.htm[l]page. And if you don't specify this parameter at all,s_timewill only do the handshake to establish SSL connections — no payload data transferred, no page, nothing.
Lowkey important: with-newand-reuse, if neither one is specified, they're both on by default and executed in sequence. So the default vibe is "do both, one after the other." 💫
🎀 SESS_ID 🎀
openssl sess_id [-cert] [-context ID] [-in file] [-inform der | pem]
[-noout] [-out file] [-outform der | pem] [-text]
The sess_id program processes the encoded version of the SSL session structure and, if you want, prints out SSL session details (like the SSL session master key, bestie 👀) in human-readable format. It's the decoder ring for your session blobs. 🦋
The options are as follows:
-cert— if a certificate is present in the session, it gets output with this option. And if-textis also there, it gets printed out in text form.-context ID— sets the session ID. The ID can be any string of characters you like, go off 💅.-in file— the input file to read from, or standard input if you don't specify one.-inform der | pem— the input format.dermeans an ASN.1 DER-encoded format containing session details — and the precise format can vary from one version to the next.pemis the default: it's the DER format, base64-encoded, with extra header and footer lines.-noout— do not output the encoded version of the session.-out file— the output file to write to, or standard output if you don't specify one.-outform der | pem— the output format.-text— prints the various public or private key components in plain text, on top of the encoded version.
The output of sess_id is composed as follows:
Protocol— the protocol in use.Cipher— the actual raw SSL or TLS cipher code.Session-ID— the SSL session ID, in hex format.Session-ID-ctx— the session ID context, in hex format.Master-Key— the SSL session master key.Key-Arg— the key argument; this is only used in SSL v2.Start Time— the session start time. Unix format.Timeout— the timeout, in seconds.Verify return code— the return code when a certificate is verified.
⚠️ Ok so real talk, this one matters: since the SSL session output contains the master key, it is possible to read the contents of an encrypted session using this information. So take appropriate security precautions if the information is being output by a "real" application. That said — this is strongly discouraged and should only be used for debugging purposes. Periodt. Do not ship this. 🚨
🌸 🦋 🌸
💌 SMIME 💌
Okay bestie, so smime is the command that handles S/MIME mail. It can encrypt, decrypt, sign, and verify S/MIME messages. That's the whole vibe — secure mail, four moves, iconic behaviour only. ✨
Real talk though: the MIME message must be sent without any blank lines between the headers and the output. Some mail programs will automatically add a blank line (rude of them, honestly) and that breaks the format. Piping the mail directly to an MTA is one way to achieve the correct format 🫶
And listen — the supplied message to be signed or encrypted must include the necessary MIME headers or many S/MIME clients won't display it properly (if at all 😭). Use the -text option to automatically add plain text headers and save yourself the heartbreak.
A "signed and encrypted" message is one where a signed message is then encrypted. You produce it by encrypting an already signed message. Layered. Main character sandwich. 🥪👑
There are a number of operations that can be performed, as follows:
-decrypt— decrypt mail using the supplied certificate and private key. The input file is an encrypted mail message in MIME format, and the decrypted mail is written to the output file.-encrypt— encrypt mail for the given recipient certificates. The input is the message to be encrypted, and the output file is the encrypted mail, in MIME format.-pk7out— take an input message and write out a PEM-encoded PKCS#7 structure.-resign— resign a message: take an existing message and one or more new signers.-sign— sign mail using the supplied certificate and private key. The input file is the message to be signed, and the signed message, in MIME format, is written to the output file.-verify— verify signed mail. The input is a signed mail message and the output is the signed data. Both clear text and opaque signing is supported. 🕵️♀️
The remaining options are as follows:
-aes128|-aes192|-aes256|-des|-des3|-rc2-40|-rc2-64|-rc2-128— the encryption algorithm to use. That's 128-, 192-, or 256-bit AES, DES (56 bits), triple DES (168 bits), or 40-, 64-, or 128-bit RC2, respectively. If you don't specify anything, 256-bit AES is used. Only used with-encrypt.-binary— normally the input message gets converted to "canonical" format, which uses CR/LF as end of line, as required by the S/MIME specification. When this option is present, no translation occurs. Useful when you're handling binary data which may not be in MIME format.-CAfile file— a file containing trusted CA certificates; only used with-verify.-CApath directory— a directory containing trusted CA certificates; only used with-verify. This directory must be a standard certificate directory: that is, a hash of each subject name (usingx509 -hash) should be linked to each certificate. (Yes, the directory layout is fussy. She's worth it. 💅)cert.pem ...— one or more certificates of message recipients; used when encrypting a message.-certfile file— lets you specify additional certificates. When signing, these will be included with the message. When verifying, these will be searched for the signers' certificates. The certificates should be in PEM format.-check_ss_sig,-crl_check,-crl_check_all,-extended_crl,-ignore_critical,-issuer_checks,-policy_check,-x509_strict— set various certificate chain validation options. See theverifycommand for details (iykyk).-content file— a file containing the detached content. This is only useful with the-verifyoption, and only usable if the PKCS#7 structure is using the detached signature form where the content is not included. This option will override any content if the input format is S/MIME and it uses themultipart/signedMIME content type.-from addr,-subject s,-to addr— the relevant mail headers. These are included outside the signed portion of a message so they may be included manually. When signing, many S/MIME mail clients check that the signer's certificate email address matches theFrom:address. 👀-in file— the input file to read from.-indef— enable streaming I/O for encoding operations. This permits single pass processing of data without the need to hold the entire contents in memory, potentially supporting very large files. Streaming is automatically set for S/MIME signing with detached data if the output format is SMIME; it is currently off by default for all other operations.-inform der | pem | smime— the input format.-inkey file— the private key to use when signing or decrypting, which must match the corresponding certificate. If this option is not specified, the private key must be included in the certificate file specified with the-recipor-signerfile. When signing, this option can be used multiple times to specify successive keys. 🔑-keyform der | pem— input private key format. The default ispem.-md digest— the digest algorithm to use when signing or resigning. If not present then the default digest algorithm for the signing key is used (usually SHA1).-noattr— do not include attributes.-nocerts— do not include the signer's certificate. This will reduce the size of the signed message but the verifier must have a copy of the signer's certificate available locally (passed using the-certfileoption, for example).-nochain— do not do chain verification of signers' certificates: that is, don't use the certificates in the signed message as untrusted CAs.-nodetach— when signing a message, use opaque signing: this form is more resistant to translation by mail relays but it cannot be read by mail agents that do not support S/MIME. Without this option, cleartext signing with the MIME typemultipart/signedis used.-noindef— disable streaming I/O where it would produce an encoding of indefinite length (currently has no effect — yes, she's just sitting there, decorative).-nointern— only use certificates specified in the-certfile. The supplied certificates can still be used as untrusted CAs.-nosigs— do not try to verify the signatures on the message.-nosmimecap— exclude the list of supported algorithms from signed attributes; other options such as signing time and content type are still included.-noverify— do not verify the signer's certificate of a signed message.-out file— the output file to write to.-outform der | pem | smime— the output format. The default issmime, which writes an S/MIME format message.pemandderchange this to write PEM and DER format PKCS#7 structures instead. This currently only affects the output format of the PKCS#7 structure; if no PKCS#7 structure is being output (for example with-verifyor-decrypt) this option has no effect. That's it, she said what she said.-passin arg— the key password source.-recip file— the recipients certificate when decrypting a message. This certificate must match one of the recipients of the message or an error occurs. No exceptions, bestie.-signer file— a signing certificate when signing or resigning a message; this option can be used multiple times if more than one signer is required. If a message is being verified, the signer's certificates will be written to this file if the verification was successful. 🎀-stream— the same as-indef.-text— add plain text (text/plain) MIME headers to the supplied message if encrypting or signing. If decrypting or verifying, it strips off text headers: if the decrypted or verified message is not of MIME typetext/plainthen an error occurs.
The exit codes for smime are as follows:
0— the operation was completely successful. slay ✨1— an error occurred parsing the command options.2— one of the input files could not be read.3— an error occurred creating the file or when reading the message.4— an error occurred decrypting or verifying the message.5— an error occurred writing certificates.
🏎️ SPEED 🏎️
openssl speed [algorithm] [-decrypt] [-elapsed] [-evp algorithm] [-mr]
[-multi number] [-unaligned number]
The speed command is used to test the performance of cryptographic algorithms. It's the "how fast can she go" command 💨
algorithm— perform the test using algorithm. The default is to test all algorithms.-decrypt— time decryption instead of encryption; must be used with-evp.-elapsed— measure time in real time instead of CPU user time.-evp algorithm— perform the test using one of the algorithms accepted byEVP_get_cipherbyname(3).-mr— produce machine readable output. (For the robots. 🤖)-multi number— run number benchmarks in parallel.-unaligned number— use allocated buffers with an offset of number bytes from the alignment provided bymalloc(3). number should be between 0 and 16.
🕐 TS 🕐
The synopsis for openssl ts:
openssl ts -query [-md4 | -md5 | -ripemd160 | -sha1] [-cert]
[-config configfile] [-data file_to_hash]
[-digest digest_bytes] [-in request.tsq] [-no_nonce]
[-out request.tsq] [-policy object_id] [-text]
openssl ts -reply [-chain certs_file.pem] [-config configfile]
[-in response.tsr] [-inkey private.pem] [-out response.tsr]
[-passin arg] [-policy object_id] [-queryfile request.tsq]
[-section tsa_section] [-signer tsa_cert.pem] [-text]
[-token_in] [-token_out]
openssl ts -verify [-CAfile trusted_certs.pem]
[-CApath trusted_cert_path] [-data file_to_hash]
[-digest digest_bytes] [-in response.tsr]
[-queryfile request.tsq] [-token_in]
[-untrusted cert_file.pem]
ok so the ts command is your basic Time Stamping Authority (TSA) client and server app, exactly as specified in RFC 3161 (Time-Stamp Protocol, TSP) 💅 A TSA can be part of a PKI deployment, and its whole ~thing~ is providing long term proof that specific data existed. Here's the protocol, babes:
- The TSA client computes a one-way hash value for a data file and sends the hash to the TSA.
- The TSA attaches the current date and time to the received hash value, signs them, and sends the time stamp token back to the client. By creating this token, the TSA certifies the existence of the original data file at the time of response generation. receipts, but cryptographic 🧾✨
- The TSA client receives the time stamp token and verifies the signature on it. It also checks if the token contains the same hash value that it had sent to the TSA.
There's one DER-encoded protocol data unit defined for transporting a time stamp request to the TSA, and one for sending the time stamp response back to the client. So the ts command has three main functions: creating a time stamp request based on a data file; creating a time stamp response based on a request; and verifying if a response corresponds to a particular request or a data file. three icons, one command 👑
ngl there is no support for sending the requests/responses automatically over HTTP or TCP yet, as suggested in RFC 3161. Users must send the requests either by FTP or email. ma'am that is genuinely on you 😭
✨ the -query switch — making a request ✨
The -query switch can be used for creating and printing a time stamp request, with the following options:
-cert— expect the TSA to include its signing certificate in the response. like, please show your ID bestie 🪪-configconfigfile — specify an alternative configuration file. Only the OID section is used.-datafile_to_hash — the data file for which the time stamp request needs to be created. The default is standard input.-digestdigest_bytes — specify the message imprint explicitly, without the data file. The imprint must be in a hexadecimal format, two characters per byte, and the bytes can optionally be separated by colons. The number of bytes must match the message digest algorithm in use. ⚠️ don't freestyle the length, it literally has to match.-inrequest.tsq — a previously created time stamp request in DER format that will be printed into the output file. Useful for examining the content of a request in human-readable format. peeking under the hood, respectfully 👀-md4|-md5|-ripemd160|-sha|-sha1— the message digest to apply to the data file. It supports all the message digest algorithms that are supported by thedgstcommand. The default isSHA1.-no_nonce— specify no nonce in the request. The default — including a 64-bit long pseudo-random nonce — is recommended to protect against replay attacks. keep the nonce, it's there for your safety babe 🔁-outrequest.tsq — the output file to write to, or standard output if not specified.-policyobject_id — the policy that the client expects the TSA to use for creating the time stamp token. Either dotted OID notation or OID names defined in the config file can be used. If no policy is requested, the TSA uses its own default policy.-text— output in human-readable text format instead of DER. for the girlies who like to actually read things 💖
A time stamp response (TimeStampResp) consists of a response status and the time stamp token itself (ContentInfo), if the token generation was successful. The -reply command is for creating a time stamp response or time stamp token based on a request, and printing the response/token in human-readable format. If -token_out is not specified, the output is always a time stamp response (TimeStampResp); otherwise it is a time stamp token (ContentInfo).
🎀 the -reply switch — making a response 🎀
-chaincerts_file.pem — the collection of PEM certificates that will be included in the response in addition to the signer certificate if the-certoption was used for the request. This file is supposed to contain the certificate chain for the signer certificate from its issuer upwards. Important: the-replycommand does not build a certificate chain automatically — you're assembling that puzzle yourself, bestie 🧩-configconfigfile — specify an alternative configuration file.-inresponse.tsr — specify a previously created time stamp response (or time stamp token, if-token_inis also specified) in DER format that will be written to the output file. This option does not require a request; it's useful, for example, to examine the content of a response or token, or to extract the time stamp token from a response. If the input is a token and the output is a time stamp response, a default "granted" status info is added to the token.-inkeyprivate.pem — the signer private key of the TSA, in PEM format. Overrides thesigner_keyconfig file option. 🔑-outresponse.tsr — the response is written to this file. The format and content of the file depends on other options (see-textand-token_out). The default is stdout.-passinarg — the key password source.-policyobject_id — the default policy to use for the response. Either dotted OID notation or OID names defined in the config file can be used. If no policy is requested, the TSA uses its own default policy.-queryfilerequest.tsq — the file containing a DER-encoded time stamp request.-sectiontsa_section — the config file section containing the settings for response generation.-signertsa_cert.pem — the PEM signer certificate of the TSA. The TSA signing certificate must have exactly one extended key usage assigned to it:timeStamping. The extended key usage must also be critical — otherwise the certificate is going to be refused. one job, critical, no exceptions 💅 Overrides thesigner_certvariable of the config file.-text— output in human-readable text format instead of DER.-token_in— the input is a DER-encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp).-token_out— the output is a time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp).
🦋 the -verify switch — is this even real 🦋
The -verify command is for verifying if a time stamp response or time stamp token is valid and matches a particular time stamp request or data file. The -verify command does not use the configuration file. no config, no vibes, just facts ✨
-CAfiletrusted_certs.pem — the file containing a set of trusted self-signed PEM CA certificates. Seeverifyfor additional details. Either this option or-CApathmust be specified.-CApathtrusted_cert_path — the directory containing the trusted CA certificates of the client. Seeverifyfor additional details. Either this option or-CAfilemust be specified.-datafile_to_hash — the response or token must be verified against file_to_hash. The file is hashed with the message digest algorithm specified in the token. The-digestand-queryfileoptions must not be specified with this one. 🚫-digestdigest_bytes — the response or token must be verified against the message digest specified with this option. The number of bytes must match the message digest algorithm specified in the token. The-dataand-queryfileoptions must not be specified with this one. 🚫-inresponse.tsr — the time stamp response that needs to be verified, in DER format. This option in mandatory. yeah, it's not optional, it's the whole point 🫶-queryfilerequest.tsq — the original time stamp request, in DER format. The-dataand-digestoptions must not be specified with this one. 🚫-token_in— the input is a DER-encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp).-untrustedcert_file.pem — additional untrusted PEM certificates which may be needed when building the certificate chain for the TSA's signing certificate. This file must contain the TSA signing certificate and all intermediate CA certificates unless the response includes them.
🌸 config file things (command line always wins) 🌸
Options specified on the command line always override the settings in the config file:
tsasection,default_tsa— this is the main section, and it specifies the name of another section that contains all the options for the-replyoption. This section can be overridden with the-sectioncommand line switch. section-ception, iconic 🌀oid_file— seecafor a description.oid_section— seecafor a description.serial— the file containing the hexadecimal serial number of the last time stamp response created. This number is incremented by 1 for each response. If the file does not exist at the time of response generation, a new file is created with serial number 1. This parameter is mandatory. 🔢signer_cert— TSA signing certificate, in PEM format. The same as the-signercommand line option.certs— a set of PEM-encoded certificates that need to be included in the response. The same as the-chaincommand line option.signer_key— the private key of the TSA, in PEM format. The same as the-inkeycommand line option.default_policy— the default policy to use when the request does not mandate any policy. The same as the-policycommand line option.other_policies— comma separated list of policies that are also acceptable by the TSA, and used only if the request explicitly specifies one of them.digests— the list of message digest algorithms that the TSA accepts. At least one algorithm must be specified. This parameter is mandatory. 🍓accuracy— the accuracy of the time source of the TSA in seconds, milliseconds and microseconds. For example,secs:1, millisecs:500, microsecs:100. If any of the components is missing, zero is assumed for that field.clock_precision_digits— the maximum number of digits, which represent the fraction of seconds, that need to be included in the time field. The trailing zeroes must be removed from the time, so there might actually be fewer digits, or no fraction of seconds at all. The maximum value is6; the default is0. ⏱️
ordering
Bestie, flip this to yes and the responses this TSA generates can always be ordered — even when the time difference between two responses is less than the sum of their accuracies. The default is no. 💅
tsa_name
Set this to yes if the subject name of the TSA must be included in the TSA name field of the response. Default is no. 🎀
ess_cert_id_chain
Okay so, the SignedData objects that the TSA creates always contain the certificate identifier of the signing certificate, sitting in a signed attribute (peep RFC 2634, Enhanced Security Services, iykyk). Now — if this option is set to yes and either the certs variable or the -chain option is specified, then the certificate identifiers of the chain get included in the SigningCertificate signed attribute too. If it's set to no, only the signing certificate identifier makes the cut. The default is no. 🌸
✨ VERIFY ✨
openssl verify [-CAfile file] [-CApath directory] [-check_ss_sig]
[-CRLfile file] [-crl_check] [-crl_check_all]
[-explicit_policy] [-extended_crl] [-help]
[-ignore_critical] [-inhibit_any] [-inhibit_map]
[-issuer_checks] [-legacy_verify] [-policy_check]
[-purpose purpose] [-trusted file] [-untrusted file]
[-verbose] [-x509_strict] [certificates]
The verify command verifies certificate chains. That's the whole vibe. 🦋
The options are as follows:
-CAfile file— a file of trusted certificates. It should hold multiple certificates in PEM format, all concatenated together. Yes, all in one file, bestie, it's fine.-CApath directory— a directory of trusted certificates. The certificates (or symbolic links pointing at them) should have names of the formhash.0, wherehashis the hashed certificate subject name (check out the-hashoption of thex509utility for that one). 🔍-check_ss_sig— verify the signature on the self-signed root CA. It's disabled by default because honestly it doesn't add any security. Not me pointing out the uselessness 💀-CRLfile file— the file should contain one or more CRLs in PEM format.-crl_check— check end entity certificate validity by attempting to look up a valid CRL. If a valid CRL cannot be found, an error occurs. No CRL, no vibe check passing. 😭-crl_check_all— check the validity of all certificates in the chain by attempting to look up valid CRLs.-explicit_policy— set policy variablerequire-explicit-policy(RFC 3280).-extended_crl— enable extended CRL features such as indirect CRLs and alternate CRL signing keys.-help— print a usage message.-ignore_critical— ignore critical extensions instead of rejecting the certificate. Living dangerously, love that for you 🙈-inhibit_any— set policy variableinhibit-any-policy(RFC 3280).-inhibit_map— set policy variableinhibit-policy-mapping(RFC 3280).-issuer_checks— print diagnostics relating to searches for the issuer certificate of the current certificate, showing why each candidate issuer certificate was rejected. Heads up tho: the presence of rejection messages does not itself imply that anything is wrong — during the normal verify process, several rejections may take place. So don't panic. 🫶-legacy_verify— use the legacy X.509 certificate chain verification code.-policy_check— enable certificate policy processing.-purpose purpose— the intended use for the certificate. Without this option, no chain verification will be done. Currently accepted uses aresslclient,sslserver,nssslserver,smimesign,smimeencrypt,crlsign,any, andocsphelper. Pick your fighter ✨-trusted file— a file of trusted certificates. It should contain multiple certificates.-untrusted file— a file of untrusted certificates. It should contain multiple certificates.-verbose— print extra information about the operations being performed.-x509_strict— disable workarounds for broken certificates, which have to be disabled for strict X.509 compliance. Strict mode: activated. 👑certificates— one or more PEM certificates to verify. If no certificate files are included, an attempt is made to read a certificate from standard input. And if the first certificate filename begins with a dash, use a lone dash to mark the last option — classic, don't get caught out. 💅
The verify program uses the same functions as the internal SSL and S/MIME verification, with one crucial difference: wherever possible, an attempt is made to continue after an error, whereas normally the verify operation would halt on the first error. This is actually iconic of it, because it lets you find all the problems with a certificate chain instead of just the first one. 🔥
The verify operation consists of a number of separate steps:
- Firstly, a certificate chain is built up starting from the supplied certificate and ending in the root CA. It is an error if the whole chain cannot be built up. The chain is built up by looking up the issuer's certificate of the current certificate. If a certificate is found which is its own issuer, it is assumed to be the root CA. 🌳
All certificates whose subject name matches the issuer name of the current certificate are subject to further tests. The relevant authority key identifier components of the current certificate (if present) must match the subject key identifier (if present) and the issuer and serial number of the candidate issuer; in addition, the keyUsage extension of the candidate issuer (if present) must permit certificate signing.
The lookup first looks in the list of untrusted certificates, and if no match is found, the remaining lookups are from the trusted certificates. The root CA is always looked up in the trusted certificate list: if the certificate to verify is a root certificate, then an exact match must be found in the trusted list. No shortcuts, bestie.
- The second operation is to check every untrusted certificate's extensions for consistency with the supplied purpose. If the
-purposeoption is not included, then no checks are done. The supplied or "leaf" certificate must have extensions compatible with the supplied purpose and all other certificates must also be valid CA certificates. The precise extensions required are described in more detail in the X509 section below. 🍓 - The third operation is to check the trust settings on the root CA. The root CA should be trusted for the supplied purpose. A certificate with no trust settings is considered to be valid for all purposes. Generous queen.
- The final operation is to check the validity of the certificate chain. The validity period is checked against the current system time and the
notBeforeandnotAfterdates in the certificate. The certificate signatures are also checked at this point. ⏰
If all operations complete successfully, the certificate is considered valid. If any operation fails, then the certificate is not valid. And when a verify operation fails, the output messages can be somewhat cryptic, ngl. The general form of the error message is:
server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024-bit)
error 24 at 1 depth lookup:invalid CA certificate
The first line contains the name of the certificate being verified, followed by the subject name of the certificate. The second line contains the error number as defined by the X509_V_ERR_* constants in <openssl/x509_vfy.h>, the associated error message documented in X509_STORE_CTX_get_error(3), and the depth. The depth is the number of the certificate being verified when a problem was detected, starting with zero for the certificate being verified itself, then 1 for the CA that signed the certificate, and so on. Counting from zero, as all things should be. 💀
🌈 VERSION 🌈
openssl version [-abdfpv]
The version command is used to print out version information about openssl. Simple. Clean. Iconic. 💖
The options are as follows:
-a— all information: this is the same as setting all the other flags. The full lore drop 📚-b— the date the current version ofopensslwas built.-d—OPENSSLDIRsetting.-f— compilation flags.-p— platform setting.-v— the currentopensslversion.
🎀 X509 🎀
openssl x509 [-addreject arg] [-addtrust arg] [-alias] [-CA file]
[-CAcreateserial] [-CAform der | pem] [-CAkey file]
[-CAkeyform der | pem] [-CAserial file] [-certopt option]
[-checkend arg] [-clrext] [-clrreject] [-clrtrust]
[-dates] [-days arg] [-email] [-enddate]
[-extensions section] [-extfile file] [-fingerprint]
[-force_pubkey key] [-hash] [-in file]
[-inform der | net | pem] [-issuer] [-issuer_hash]
[-issuer_hash_old] [-keyform der | pem] [-md5 | -sha1]
[-modulus] [-multivalue-rdn] [-nameopt option] [-new]
[-next_serial] [-noout] [-ocsp_uri] [-ocspid] [-out file]
[-outform der | net | pem] [-passin arg] [-pubkey]
[-purpose] [-req] [-serial] [-set_issuer name]
[-set_serial n] [-set_subject name] [-setalias arg]
[-signkey file] [-sigopt nm:v] [-startdate] [-subject]
[-subject_hash] [-subject_hash_old] [-text] [-trustout]
[-utf8] [-x509toreq]
The x509 command is a multi-purpose certificate utility — it does everything, main character energy fr. It can be used to display certificate information, convert certificates to various forms, sign certificate requests like a "mini CA", or edit certificate trust settings. Obsessed with the range. 👑
The following are x509 input, output, and general purpose options:
-in file— the input file to read from, or standard input if not specified. This option cannot be used with-new. Pick a lane, bestie. 🚫-inform der | net | pem— the input format. Normally the command will expect an X.509 certificate, but this can change if other options such as-inor-reqare present. Plot twist potential ✨-md5 | -sha1— the digest to use. This affects any signing or display option that uses a message digest, such as the-fingerprint,-signkey, and-CAoptions. If not specified,MD5is used.SHA1is always used with DSA keys, no negotiating on that one.-out file— the output file to write to, or standard output if none is specified.-outform der | net | pem— the output format.-passin arg— the key password source.
The following are x509 display options:
-certopt option— customise the output format used with-text, either by using a list of comma-separated options or by specifying-certoptmultiple times. The default behaviour is to print all fields. The options are as follows:ca_default— lowkey the "just give me the defaults" bundle: it's exactlyno_issuer,no_pubkey,no_header,no_version,no_sigdump, andno_signameserving looks together.compatible— equivalent to literally no output options at all. minimalist queen behaviour ✨ext_default— print the unsupported certificate extensions.ext_dump— hex dump the unsupported extensions.ext_error— print an error message for unsupported certificate extensions.ext_parse— ASN.1 parse the unsupported extensions.no_aux— do not print certificate trust information.no_extensions— do not print X509V3 extensions.no_header— do not print header (Certificate and Data) information.no_issuer— do not print the issuer name.no_pubkey— do not print the public key.no_serial— do not print the serial number.no_sigdump— no hexadecimal dump of the certificate signature, pls and thank u.no_signame— do not print the signature algorithm used.no_subject— do not print the subject name.no_validity— do not print the notBefore and notAfter (validity) fields.no_version— do not print the version number.
-dates— print the start and expiry date of a certificate. the little timeline moment 🎀-email— output the email addresses, if any.-enddate— print the expiry date of the certificate; that is, the notAfter date.-fingerprint— print the digest of the DER-encoded version of the whole certificate.-hash— a synonym for-subject_hash.-issuer— print the issuer name.-issuer_hash— print the hash of the certificate issuer name.-issuer_hash_old— print the hash of the certificate issuer name using the older algorithm as used by openssl versions before1.0.0. vintage behaviour, we respect it 🫶-modulus— print the value of the modulus of the public key contained in the certificate.-multivalue-rdn— this option causes the-subjargument to be interpreted with full support for multivalued RDNs, for example"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe". If-multivalue-rdnis not used, the UID value is set to"123456+CN=John Doe". iykyk — the+only does its thing when u ask nicely 💅-nameoptoption — customise how the subject or issuer names are displayed, either using a list of comma-separated options or by specifying-nameoptmultiple times. the default behaviour is to use thecompatformat. the options, which can be preceded by a dash to turn them off, are as follows:align— align field values for a more readable output. only usable withsep_multiline. aesthetic ✅compat— use the old format, equivalent to specifying no options at all.dn_rev— reverse the fields of the DN, as required by RFC 2253. as a side effect, this also reverses the order of multiple AVAs.dump_all— dump all fields. when used withdump_der, it allows the DER encoding of the structure to be unambiguously determined.dump_der— any fields that need to be hexdumped are dumped using the DER encoding of the field. otherwise just the content octets will be displayed. both options use the RFC 2253#XXXX...format.dump_nostr— dump non-character string types (for example OCTET STRING); usually, non-character string types are displayed as though each content octet represents a single character.dump_unknown— dump any field whose OID is not recognised by openssl.esc_2253— escape the "special" characters required by RFC 2253 in a field that is“ ,+"<>;”. additionally,‘#’is escaped at the beginning of a string and a space character at the beginning or end of a string.esc_ctrl— escape control characters. that is, those with ASCII values less than0x20(space) and the delete (0x7f) character. they are escaped using the RFC 2253\XXnotation (where XX are two hex digits representing the character value).esc_msb— escape characters with the MSB set; that is, with ASCII values larger than127.multiline— a multiline format. equivalent toesc_ctrl,esc_msb,sep_multiline,space_eq,lname, andalign.no_type— do not attempt to interpret multibyte characters. that is, content octets are merely dumped as though one octet represents each character. this is useful for diagnostic purposes but results in rather odd looking output. 😭 it's giving unreadable but make it on purposenofname,sname,lname,oid— alter how the field name is displayed:nofnamedoes not display the field at all;snameuses the short name form (CNforcommonName, for example);lnameuses the long form.oidrepresents the OID in numerical form and is useful for diagnostic purpose.oneline— a one line format which is more readable than RFC2253. equivalent toesc_2253,esc_ctrl,esc_msb,utf8,dump_nostr,dump_der,use_quote,sep_comma_plus_space,space_eq, andsname.RFC2253— displays names compatible with RFC 2253. equivalent toesc_2253,esc_ctrl,esc_msb,utf8,dump_nostr,dump_unknown,dump_der,sep_comma_plus,dn_rev, andsname. the compliance icon 👑sep_comma_plus,sep_comma_plus_space,sep_semi_plus_space,sep_multiline— determine the field separators: the first character is between RDNs and the second between multiple AVAs (multiple AVAs are very rare and their use is discouraged). the options ending in "space" additionally place a space after the separator to make it more readable.sep_multilineuses a linefeed character for the RDN separator and a spaced‘+’for the AVA separator, as well as indenting the fields by four characters. if no field separator is specified thensep_comma_plus_spaceis used by default.show_type— show the type of the ASN.1 character string. the type precedes the field contents. for example"BMPSTRING: Hello World".space_eq— place spaces round the‘=’character which follows the field name.use_quote— escape some characters by surrounding the whole string with‘"’characters. without the option, all escaping is done with the‘\’character.utf8— convert all strings to UTF8 format first, as required by RFC 2253. on a UTF8 compatible terminal, the use of this option (and not settingesc_msb) may result in the correct display of multibyte characters. usually, multibyte characters larger than0xffare represented using the format\UXXXXfor 16 bits and\WXXXXXXXXfor 32 bits, and any UTF8Strings are converted to their character form first.
-next_serial— print the next serial number.-noout— do not output the encoded version of the request.-ocsp_uri— print the OCSP responder addresses, if any.-ocspid— print OCSP hash values for the subject name and public key.-pubkey— print the public key.-serial— print the certificate serial number.-sigoptnm:v — pass options to the signature algorithm during sign or certify operations. the names and values of these options are algorithm-specific.-startdate— print the start date of the certificate; that is, the notBefore date.-subject— print the subject name.-subject_hash— print 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. the whole filing-system vibe, honestly iconic 🗂️-subject_hash_old— print the hash of the certificate subject name using the older algorithm as used by openssl versions before1.0.0.-text— print the full certificate in text form. the "just show me everything" option, and yes we love her for it 💖
ok so a trusted certificate is a certificate which has several additional pieces of information attached to it such as the permitted and prohibited uses of the certificate and an alias. when a certificate is being verified, at least one certificate must be trusted. by default, a trusted certificate must be stored locally and be a root CA. the following are x509 trust settings options:
-addrejectarg — add a prohibited use. accepts the same values as the-addtrustoption.-addtrustarg — add a trusted certificate use. any object name can be used here, but currently onlyclientAuth(SSL client use),serverAuth(SSL server use), andemailProtection(S/MIME email) are used.-alias— output the certificate alias.-clrreject— clear all the prohibited or rejected uses of the certificate.-clrtrust— clear all the permitted or trusted uses of the certificate.-purpose— perform tests on the certificate extensions. the same code is used when verifying untrusted certificates in chains, so this section is useful if a chain is rejected by the verify code.
the basicConstraints extension CA flag is used to determine whether the certificate can be used as a CA. if the CA flag is true, it is a CA; if the CA flag is false, it is not a CA. all CAs should have the CA flag set to true.
if the basicConstraints extension is absent, then the certificate is considered to be a possible CA; other extensions are checked according to the intended use of the certificate. a warning is given in this case because the certificate should really not be regarded as a CA. however it is allowed to be a CA to work around some broken software. 🫠 we do a lil trolling, as a treat
if the certificate is a V1 certificate (and thus has no extensions) and it is self-signed, it is also assumed to be a CA but a warning is again given. this is to work around the problem of Verisign roots which are V1 self-signed certificates.
So yeah — if the keyUsage extension is present, there are extra restrictions on how the cert can be used. A CA certificate must have the keyCertSign bit set if keyUsage is present. No exceptions, bestie. 💅
The extended key usage extension also piles on restrictions: if it's there — critical or not, doesn't matter — the key can only be used for the purposes it specifies. Periodt.
A full rundown of every test is below 👇 and the notes about basicConstraints, keyUsage and V1 certificates from above apply to all CA certificates. Every single one. 💀
SSL Client
The extended key usage extension has to be absent, or include the web client authentication OID. keyUsage has to be absent, or it must have the digitalSignature bit set. And the Netscape certificate type must be absent, or it must have the SSL client bit set.
SSL Client CA
The extended key usage extension has to be absent, or include the web client authentication OID. The Netscape certificate type must be absent, or it must have the SSL CA bit set — this one's used as a workaround if the basicConstraints extension is absent. iykyk 🫶
SSL Server
The extended key usage extension must be absent, or include the web server authentication and/or one of the SGC OIDs. keyUsage must be absent, or it must have digitalSignature set, keyEncipherment set, or both bits set. The Netscape certificate type must be absent, or have the SSL server bit set.
SSL Server CA
The extended key usage extension must be absent, or include the web server authentication and/or one of the SGC OIDs. The Netscape certificate type must be absent, or the SSL CA bit must be set — again, workaround duty when basicConstraints is absent. 🎀
Netscape SSL Server
This is for Netscape SSL clients connecting to an SSL server. It must have the keyEncipherment bit set if the keyUsage extension is present. Ngl, this isn't always valid, because some cipher suites use the key for digital signing. Otherwise it's the same as a normal SSL server.
Common S/MIME Client Tests
The extended key usage extension must be absent, or include the email protection OID. The Netscape certificate type must be absent, or should have the S/MIME bit set. And if the S/MIME bit isn't set in the Netscape certificate type, then the SSL client bit is tolerated as an alternative — but you get a warning, because some Verisign certificates don't set the S/MIME bit. 🙈
S/MIME Signing
On top of the common S/MIME client tests, the digitalSignature bit must be set if the keyUsage extension is present.
S/MIME Encryption
On top of the common S/MIME tests, the keyEncipherment bit must be set if the keyUsage extension is present.
S/MIME CA
The extended key usage extension must be absent, or include the email protection OID. The Netscape certificate type must be absent, or must have the S/MIME CA bit set — you guessed it, workaround for a missing basicConstraints. ✨
CRL Signing
The keyUsage extension must be absent, or it must have the CRL signing bit set.
CRL Signing CA
The normal CA tests apply, except the basicConstraints extension must be present. (Yes, that's the twist. Not me double-checking. 😭)
-setalias arg— Sets the alias of the certificate, so you can refer to it by a nickname — like"Steve's Certificate". Cute, right? 🎀-trustout— Outputs a trusted certificate (this is the default if any trust settings are modified). You can feed it an ordinary or a trusted certificate, but by default an ordinary certificate is output and any trust settings are discarded. Bye trust settings, you will not be missed 💀
The x509 utility can be used to sign certificates and requests, which basically means it can act like a mini CA. 👑 The following are the x509 signing options:
-CA file— The CA certificate used for signing. When this option's present,x509behaves like a mini CA. The input file gets signed by the CA using this option — meaning its issuer name is set to the subject name of the CA, and it's digitally signed using the CA's private key. This option is normally combined with the-reqoption. Without-req, the input is a certificate, and it must be self-signed.-CAcreateserial— Creates the CA serial number file if it doesn't already exist, instead of throwing an error. The file will contain the serial number‘02’and the certificate being signed will have‘1’as its serial number. Slay, numbers. 🔢-CAform der | pem— The format of the CA certificate file. Default ispem.-CAkey file— Sets the CA private key to sign a certificate with. If you don't, it's assumed the CA private key lives inside the CA certificate file.-CAkeyform der | pem— The format of the CA private key. Default ispem.-CAserial file— Uses the serial number in file to sign a certificate. The file should consist of one line containing an even number of hex digits — that's the serial number to use. After each use, the serial number is incremented and written back out to the file again. 🔁 The default filename is the CA certificate file's base name with.srlappended. So like, if your CA certificate file is calledmycacert.pem, it expects to find a serial number file calledmycacert.srl. Consistency queen 🎀-checkend arg— Checks whether the certificate expires within the next arg seconds. If it does, exit with return value1; otherwise exit with return value0.-clrext— Deletes any extensions from a certificate. This option is used when a certificate is being created from another certificate (for example with the-signkeyor the-CAoptions). Normally, all extensions are retained. 🗑️-days arg— How many days the certificate should be valid for. Default is30days.-extensions section— The section to add certificate extensions from. If you don't specify this option, the extensions should either be inside the unnamed (default) section, or the default section should contain a variable called"extensions"that holds the section to use.-extfile file— File containing the certificate extensions to use. If not specified, no extensions get added to the certificate.-force_pubkey key— Sets the public key of the certificate to the public key contained in key. 🔑-keyform der | pem— The format of the key file used in the-force_pubkeyand-signkeyoptions.-new— Generates a new certificate using the subject given by-set_subjectand signed by-signkey. If no public key is provided with-force_pubkey, the resulting certificate is self-signed. This option cannot be used with-inor-req. ⚠️-req— Expects a certificate request on input instead of a certificate. This option cannot be used with-new.-set_issuer name— The issuer name to use. name must be formatted as/type0=value0/type1=value1/type2=...; characters may be escaped by‘\’(backslash); no spaces are skipped. 🫶-set_serial n— The serial number to use. This option can be used with either the-signkeyor-CAoptions. If you use it together with the-CAoption, the serial number file (as specified by the-CAserialor-CAcreateserialoptions) is not used. The serial number can be decimal or hex (if preceded by‘0x’). Negative serial numbers can also be specified, but their use is not recommended. 🙈-set_subject name— The subject name to use. name must be formatted as/type0=value0/type1=value1/type2=...; characters may be escaped by‘\’(backslash); no spaces are skipped.-signkey file— Self-signs file using the supplied private key. ✍️ If the input file is a certificate, it sets the issuer name to the subject name (i.e. it makes it self-signed), changes the public key to the supplied value, and changes the start and end dates. The start date gets set to the current time, and the end date gets set to a value determined by the-daysoption. Any certificate extensions are retained unless you supply the-clrextoption. If the input is a certificate request, a self-signed certificate is created using the supplied private key, using the subject name in the request.-utf8— Interprets field values read from a terminal or obtained from a configuration file as UTF-8 strings. By default, they're interpreted as ASCII. 🌈-x509toreq— Converts a certificate into a certificate request. The-signkeyoption is used to pass the required private key. 🦋
💖 COMMON NOTATION 💖
A bunch of these commands share the same little syntax club, and here's the tea. ☕
🔐 password arguments
Password arguments — usually -passin for the input password and -passout for the output password — let you grab a password from a whole menu of sources. Both take a single argument. If no password argument is given and a password is required, you get prompted: it'll typically read from your current terminal with echoing turned off. So your typing stays lowkey invisible. ✨
pass:password— the actual password ispassword. warning: it's visible to utilities, so only use this when security isn't important. no cap.env:var— get the password from environment variablevar. caution: other processes can see the environment, so use this one carefully.file:path— the first line ofpathis the password. If you pass the samepathto both-passinand-passout, the first line is the input password and the next line is the output password.pathdoesn't have to be a regular file — it could be a device or a named pipe, for example. 🫶fd:number— read the password from file descriptornumber. This is how you can send the data through a pipe, for example.stdin— read the password from standard input.
🎀 input/output formats
Input/output formats — usually -inform and -outform — tell openssl what format it's reading or writing. The argument is case insensitive, bestie. 💅
der— Distinguished Encoding Rules (DER), a binary format.net— insecure legacy format. yikes, legacy.pem— Privacy Enhanced Mail (PEM), which is base64-encoded.pvk— Private Key format.smime— an SMIME format message.txt— plain ASCII text.
🌸 ENVIRONMENT 🌸
These environment variables affect how openssl runs:
OPENSSL_CONF— the location of the master configuration file. 👑
🎀 FILES 🎀
/etc/ssl/— default config directory for openssl./etc/ssl/lib/— unused. she's just there, vibing./etc/ssl/private/— default private key directory. 🔐/etc/ssl/openssl.cnf— default configuration file for openssl./etc/ssl/x509v3.cnf— default configuration file for x509 certificates.
🦋 SEE ALSO 🦋
Go be nosy in these pages, bestie: acme-client(1), nc(1), openssl.cnf(5), x509v3.cnf(5), ssl(8), starttls(8). 💖
⭐ STANDARDS ⭐
The receipts, aka the standards this page is serving:
- T. Dierks and C. Allen, The TLS Protocol Version 1.0, RFC 2246, January 1999.
- M. Wahl, S. Killie, and T. Howes, Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names, RFC 2253, December 1997.
- B. Kaliski, PKCS #7: Cryptographic Message Syntax Version 1.5, RFC 2315, March 1998.
- R. Housley, W. Ford, W. Polk, and D. Solo, Internet X.509 Public Key Infrastructure Certificate and CRL Profile, RFC 2459, January 1999.
- M. Myers, R. Ankney, A. Malpani, S. Galperin, and C. Adams, X.509 Internet Public Key Infrastructure Online Certificate Status Protocol – OCSP, RFC 2560, June 1999.
- R. Housley, Cryptographic Message Syntax, RFC 2630, June 1999.
- P. Chown, Advanced Encryption Standard (AES) Ciphersuites for Transport Layer Security (TLS), RFC 3268, June 2002.
and that's the whole manual page, bestie. 💅
💖 that's a wrap! source/version: Debian; date: March 14, 2026; page: OPENSSL(1). periodt. 💖
📦 where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 · custom
- Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved
- Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms