Skip to content

Instantly share code, notes, and snippets.

@framon
Created April 27, 2020 18:02
Show Gist options
  • Save framon/0704c1991cf36264c5a29b9864d6c125 to your computer and use it in GitHub Desktop.
Save framon/0704c1991cf36264c5a29b9864d6c125 to your computer and use it in GitHub Desktop.

Gerar chave privada da CA

openssl genrsa -out ca.key 2048

Gerar certificado da CA autoassinado

openssl req -new -x509 -days 365 -key ca.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=Acme Root CA" -out ca.crt

Gerar a requisição de certificado com SAN

openssl req -newkey rsa:2048 -nodes -addext "subjectAltName = otherName:2.16.76.1.3.1;IA5STRING:010119801234567857700000000000000001234567890SSPBA" -keyout person.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=Acme CTO" -out person.csr

Assinar o certificado pela CA

openssl x509 -req -extensions SAN -extfile <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=otherName:2.16.76.1.3.1;IA5STRING:010119801234567857700000000000000001234567890SSPBA,email:cto@acme.com")) -days 365 -in person.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out person.crt

Obs: Foi necessário repetir a inclusão do SAN pois o processo de assintatura estava descartando e não parei para analisar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment