LinuxCommandLibrary

openssl-req

creates and processes certificate signing requests

TLDR

Generate CSR with new key

$ openssl req -new -newkey rsa:[4096] -keyout [private.key] -out [request.csr]
copy
Generate CSR from existing key
$ openssl req -new -key [private.key] -out [request.csr]
copy
Generate self-signed certificate
$ openssl req -x509 -newkey rsa:[4096] -keyout [key.pem] -out [cert.pem] -days [365] -nodes
copy
View CSR contents
$ openssl req -in [request.csr] -text -noout
copy
Generate CSR with config file
$ openssl req -new -config [openssl.cnf] -keyout [key.pem] -out [request.csr]
copy

SYNOPSIS

openssl req [options]

DESCRIPTION

openssl req creates and processes certificate signing requests (CSRs). It can also generate self-signed certificates for testing.
CSRs are submitted to Certificate Authorities to obtain signed certificates.

PARAMETERS

-new

Generate new CSR.
-x509
Output certificate instead of CSR.
-newkey type:bits
Generate new key.
-key file
Use existing key.
-keyout file
Output key file.
-out file
Output file.
-days n
Validity period.
-nodes
Don't encrypt key.
-subj subj
Subject DN.

SUBJECT FORMAT

$ openssl req -new -key key.pem -out csr.pem \
  -subj "/C=US/ST=State/L=City/O=Org/CN=example.com"
copy

CAVEATS

Self-signed certs not trusted by browsers. Use -nodes carefully. CSR doesn't contain private key.

HISTORY

Certificate request functionality has been part of OpenSSL since its SSL/TLS implementation origins.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community