Simple SSL cert - HOWTO

You will need openssl.
  • Make a new ssl private key:

    • Generate a new unencrypted rsa private key in PEM format:
          openssl genrsa -out privkey.pem 1024
      
      You can create an encrypted key by adding the -des3 option.

  • To make a self-signed certificate:

    • Create a certificate signing request (CSR) using your rsa private key:
          openssl req -new -key privkey.pem -out certreq.csr
      
      ( This is also the type of CSR you would create to send to a root CA for them to sign for you. )

    • Self-sign your CSR with your own private key:
          openssl x509 -req -days 3650 -in certreq.csr -signkey privkey.pem -out newcert.pem
      

  • To make a certificate signed by your own certificate authority (CA):

    • Configure /etc/ssl/openssl.cnf and use CA.pl to create the CA private key and certificate:
          vi /etc/ssl/openssl.cnf
          /usr/lib/ssl/misc/CA.pl -newca
      
      Your copy of openssl.cnf and CA.pl may be located elsewhere.

    • Create an unsigned certificate using your rsa private key:
          openssl req -new -x509 -key privkey.pem -out cert.pem
      
    • Use your private key and your certificate to make a CSR:
          cat cert.pem privkey.pem | openssl x509 -x509toreq -signkey privkey.pem -out certreq.csr
      
    • Sign the certificate with the CA private key using the CSR you just made:
          openssl ca -in certreq.csr -out newcert.pem
          rm -f certreq.csr
      

  • To install the signed certificate and private key for use by an ssl server:

    • The newcert.pem is the certificate signed by your local CA that you can then use in an ssl server:
          ( openssl x509 -in newcert.pem; cat privkey.pem ) > server.pem
          ln -s server.pem `openssl x509 -hash -noout -in server.pem`.0   # dot-zero
      
      ( The server.pem is a PEM file that can be used by apache along with the hash file. )


    You can view the contents of a CSR with:
        openssl req -noout -text -in certreq.csr
    
    You can view the contents of a certificate with:
        openssl x509 -noout -text -in newcert.pem
    
    You can display the MD5 fingerprint of a certificate with:
        openssl x509 -fingerprint -noout -in newcert.pem
    
    You can verify that your private key, CSR, and signed cert match by comparing:
        openssl rsa -noout -modulus -in privkey.pem |openssl md5
        openssl req -noout -modulus -in certreq.csr |openssl md5
        openssl x509 -noout -modulus -in newcert.pem |openssl md5
    

    See Also:
    openssl certificates howto
    openssl keys howto
    brief CA and CERT howto
    CA and CERT howto
    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值