OpenSSL Certificate (Version 3) with Subject Alternative Name

后端 未结 9 1902

I\'m using the OpenSSL command line tool to generate a self signed certificate. It seems to be working correctly except for two issues. I can\'t get it to create a .cer with a S

9条回答
  •  故里飘歌
    2021-01-31 04:03

    I referred to several pages, and the most significant helps are from 1. https://geekflare.com/san-ssl-certificate/, 2. https://certificatetools.com/ (see answer from user40662), and 3. answer from Raghu K Nair about the command usage.

    Then my successful try:

    san.cnf

    [ req ]
    default_bits       = 2048
    default_md         = sha256
    distinguished_name = req_distinguished_name
    req_extensions     = v3_req
    [ req_distinguished_name ]
    countryName            = CN                     # C=
    stateOrProvinceName    = Shanghai               # ST=
    localityName           = Shanghai               # L=
    #postalCode             = 200000                 # L/postalcode=
    #streetAddress          = "My Address"           # L/street=
    organizationName       = My Corporation         # O=
    organizationalUnitName = My Department          # OU=
    commonName             = myname.mysoftware.mycorporation.com # CN=
    emailAddress           = myname@example.com     # CN/emailAddress=
    [ v3_req ]
    subjectAltName = @alt_names
    [ alt_names ]
    DNS.1   = myname.mysoftware.mycorporation.com
    #DNS.2   = other2.com
    #DNS.3   = other3.com
    

    Command:

    openssl req -x509 -nodes -days 365 -subj "/C=CN/ST=Shanghai/L=Shanghai/O=My Corporation/OU=My Department/CN=myname.mysoftware.mycorporation.com/emailAddress=myname@example.com" -keyout privateKey.pem -out certificate.crt -config san.cnf -extensions v3_req
    

提交回复
热议问题