OpenSSL生成SSL証明書

2725 ワード

1.CA証明書の作成
  • ca.key CA秘密鍵ステップは、OpenSSLを使用してサーバhttps証明書を発行することと大きく異なる.
    openssl genrsa -des3 -out ca.key 2048    //  ca.key   
    //       
    
  • 復号後のCA秘密鍵を作成する(一般的には必要ない)
    openssl rsa -in ca.key -out ca_decrypted.key
    //  ca.key   
    
    //    ca   ca  :
    ca_decrypted.key  
    ca.key              
    
  • .
  • ca.crt CAルート証明書(公開鍵)
    openssl req -new -x509 -days 7305 -key ca.key -out ca.crt
    //  ca.key       
    
    //      
    Country Name (2 letter code) [XX]:             //         ,          
    State or Province Name (full name) []:         //      ,        
    Locality Name (eg, city) [Default City]:       //    ,        
    Organization Name (eg, company) [Default Company Ltd]:         //    ,          
    Organizational Unit Name (eg, section) []:        //       ,      
    Common Name (eg, your name or your server’s hostname) []:www.amber.com     //     (                ),        ,  
    Email Address []:  //    ,   
    
    Please enter the following ‘extra’ attributes
    to be sent with your certificate request
    A challenge password []:    //        
    An optional company name []:ZX    //         
    
    //   ca  
    ca.crt  
    ca_decrypted.key  
    ca.key           
    
  • 2.生成サイトの証明書を作成し、CA署名で認証する
  • www.amberを生成する.comt証明書秘密鍵
    openssl genrsa -des3 -out www.amber.com.pem 2048
    //  www.amber.com.pem  
    //    www.amber.com.pem  
    
  • 解読後のwww.amberを作成する.oom証明書秘密鍵
    openssl rsa -in www.amber.com.pem -out www.amber.com.key
    //  www.amber.com.pem  
    
    //    wwwamber.com.key    
    ca.crt  
    ca_decrypted.key  
    ca.key  
    www.amber.com.key  
    www.amber.com.pem
    
  • 署名要求
    openssl req -new -key www.amber.com.pem -out www.amber.com.csr
    //  www.amber.com.pem     
    //      ,     
    // : common name       , blog.creke.net          ,           *.creke.net                
    
  • を生成する.
  • CAによる署名
    openssl ca -policy policy_anything -days 1460 -cert ca.crt -keyfile ca.key -in www.amber.com.csr -out www.amber.com.crt
    //  ca    
    
  • エラー解決
    /etc/pki/CA/index.txt: No such file or directory unable to open '/etc/pki/CA/index.txt'//エラーメッセージ、このディレクトリを開くことができません..140576737036104:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('/etc/pki/CA/index.txt','r')
    署名コマンドを実行すると、「I am unable to access the...//CA/newcerts directory」が表示されます.
        /etc/pki/CA/
          :
    touch CA/index.txt
    touch CA/serial
    echo "01" > CA/serial
    
    署名コマンドを再実行します.
  • ca.crtの内容をwww.amberに貼り付けます.com.crtの後はこれが重要です.そうしないと、一部のブラウザがサポートしない可能性があります.
    cat ca.crt >> www.amber.com.crt
    
    証明書が生成され、サーバで使用できるようになりました.