2008年7月8日 星期二

幫 Linux 向企業 CA 申請網頁伺服器憑證(適用 Fedora Core 7)

 一般中大型企業會用 Windows 架設企業內部 CA Server,在 IIS 上申請憑證沒什麼太大問題,而 Linux 要如何向 Windows 的 CA Server 申請網頁伺服器憑證呢?

一、建立申請憑證
 1. 建立私密金鑰 Server.key
  # openssl genrsa –out server.key 1024  Generating RSA private key, 1024 bit long modulus
  ....................................................................++++++
  ....++++++
  e is 65537 (0x10001)


 2. 建立 Server.csr 憑證申請
  # openssl req –new –key server.key –out server.csr
  You are about to be asked to enter information that will be incorporated
  into your certificate request.
  What you are about to enter is what is called a Distinguished Name or a DN.
  There are quite a few fields but you can leave some blank
  For some fields there will be a default value,
  If you enter '.', the field will be left blank.
  -----
  Country Name (2 letter code) [GB]: TW <- 國家
  State or Province Name (full name) [Berkshire]:Taiwan <- 省份
  Locality Name (eg, city) [Newbury]:Taipei <- 城市
  Organization Name (eg, company) [My Company Ltd]:XYZ <-公司名稱  Organizational Unit Name (eg, section) []:MIS <- 單位名稱
  Common Name (eg, your name or your server's hostname) []:www.abc.com.tw <- 網站的 FQDN
  Email Address []:service@abc.com.tw <- 管理者Mail
  Please enter the following 'extra' attributes
  to be sent with your certificate request
  A challenge password []: <- 直接按"Enter"
  An optional company name []: <- 直接按"Enter"


 3. 執行後將產生 server.csr 檔案,此檔案要交給企業 CA 或第三方公信單位產生 Server.crt 憑證。


二、申請網頁伺服器憑證
 1. 開啟企業 CA 憑證申請網頁,點選「要求憑證」

 2. 點選「進階憑證要求」

 3. 點選「用 Base-64 編碼的 CMC 或 PKCS #10 檔案來提交憑證......更新要求」

 4. 將 Linux 上產生的 server.csr 內容,貼到「Base-64 編碼的憑證要求」內,並將憑證範本選擇「網頁伺服器」(註:如果看不到網頁伺服器選項,表示使用一般使用者身份申請憑證,請切換使用者身份為 Domain Admin,重新申請),然後點選「提交」送出憑證申請。

 5. 選擇 DER 編碼或 Base 64 編碼都可以,點選「下載憑證」,儲存申請好的 certnew.cer 網頁伺服器憑證。


三、安裝憑證
 1. 將申請下來的 certnew.cer 複製到 Linux 上,並將副檔名更改為 certnew.crt。


 2. 將 certnew.crt 搬移到憑證存放路徑下:
  /etc/pki/tls/certs/ <- 各 Linux 版本路徑不同


 3. 將剛才在 Linux 上所產生的 server.key 搬移到金鑰存放路徑下:
  /etc/pki/tls/private/ <- 各 Linux 版本路徑不同


 4. 編輯 /etc/httpd/conf.d/ssl.conf
  SSLCertificateFile /etc/pki/tls/certs/certnew.crt <- 修改新的憑證名稱
  SSLCertificateKeyFile /etc/pki/tls/private/server.key <- 修改新的金鑰名稱


 5. 重新啟動服務 service httpd restart

沒有留言:

張貼留言