用openssl建立公開金鑰私密金鑰認證的指令碼

來源:互聯網
上載者:User

標籤:公開金鑰   私密金鑰   openssl   


MacBook-Pro:key username$ vim ./createselfsignedcertificate.sh 


內容如下:


  mkdir data

  cd data

  #建立認證授權中心(CA)的私密金鑰

  openssl genrsa -out ca.pem 2048

  #利用CA的私密金鑰建立根憑證

  openssl req -new -x509 -days 36500 -key ca.pem -out ca.crt -subj \

  "/C=CN/ST=Beijing/L=Beijing/O=Beijing AAA Information Technology Co., Ltd./OU=IT Department/CN=aaa.cn"

  #建立伺服器私密金鑰

  openssl genrsa -out server.pem 2048

  #利用伺服器私密金鑰建立SSL認證

  openssl req -new -days 3650 -key server.pem -out server.csr -subj \

  "/C=CN/ST=Beijing/L=Beijing/O=Beijing AAA Information Technology Co., Ltd./OU=IT Department/CN=aaa.cn"

  #匯出伺服器公開金鑰

  openssl rsa -in server.pem -outform PEM -pubout -out public.pem

  #為建立簽署憑證做準備

  mkdir demoCA

  cd demoCA

  mkdir newcerts

  touch index.txt

  echo ‘01‘ > serial

  cd ..

  #用CA根憑證簽署伺服器憑證

  openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.pem

  #建立pkcs12格式的伺服器私密金鑰檔案,用於tomcat伺服器配置

  openssl pkcs12 -export -in server.crt -inkey server.pem -out server.p12 -name tomcat -CAfile ca.crt -caname root -chain

  


本文出自 “GONE WITH THE WIND” 部落格,請務必保留此出處http://h2appy.blog.51cto.com/609721/1665888

用openssl建立公開金鑰私密金鑰認證的指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.