服務器證書安裝配置指南(Weblogic) html
以前在網上找了好多資料,按照步奏執行,可是最後都不行,都缺了一點,最後終於整合起來了,從本身製做CA證書到weblogic配置和客戶端IE設置,所有OK java
1、環境準備 linux
1. 安裝JDK(可選)
Weblogic安裝後自帶JDK安裝。若是您直接在服務器上生成證書請求,請進入Weblogic安裝目錄下JDK所在路徑的bin目錄,運行keytool命令。
若是您須要在其餘環境下生成證書請求文件,則您能夠選擇安裝JDK,並稍後上傳生成的密鑰庫文件keystore.jks到服務器上進行配置。
Java SE Development Kit (JDK) 下載。下載地址:
http://www.oracle.com/technetwork/java/javase/downloads/index.html web
2、準備openssl apache
先決條件:從openssl官網下載www.openssl.org windows
安裝openssl[windows和linux安裝不一樣] 瀏覽器
若是沒有配置環境變量,則須要進入openssl的bin目錄下執行命令,如:C:/OpenSSL/bin,這個不對了,我下載的是最新的openssl-0.9.8zc,沒有bin,目錄,測試了下,能夠在win7下直接用C:\openssl-0.9.8zc這個目錄執行, 服務器
若只配置了環境變量,則在任意位置均可以執行 oracle
在執行命令前,新建兩個目錄ca和server,這個要注意哦,在openssl-0.9.8zc這個裏面建立 dom
1、 使用openssl製做CA證書和服務器證書
目前不使用第三方權威機構的CA來認證,由於須要收費,因此咱們本身使用openssl來製做CA證書和服務器證書,本身充當CA的角色。
一:生成CA證書
1. 建立私鑰 :
openssl genrsa -out ca/ca-key.pem 1024
2.建立證書請求 :
openssl req -new -out ca/ca-req.csr -key ca/ca-key.pem
這句執行出錯啦,結果出現了這個錯誤:Unable to load config info from /usr/local/ssl/openssl.cnf
百度了一下,按照後面藍色這一段執行就OK
原來是直接使用了別人生成好的密鑰,惋惜他是在Unix上用的,不適合Win32!沒有辦法,重新開始整openSSO,可是呢,在使用openSSO的時候,出現了 [Unable to load config info from /usr/local/ssl/openssl.cnf ] 異常.然原來這是Unix的默認設置,沒有辦法,只好建文件[c:/usr/local/ssl],從網上下載openssl.conf,而後改成openssl.cnf,置於c:/usr/local/ssl目錄下,好了,終於搞定密鑰了,Apache也能夠啓動了,慶祝一下。
訪問https://localhost/login,是白屏,是沒有啓動Apache的SSL,在CMD下運行apache -D SSL,OK,一切都搞定了。
一些優化的方法,就是在ssl.conf文件中,註釋掉<IfDefine SSL>,就能夠直接啓動SSL了。
在配置中,還有一些問題,好比,[ Invalid SSLMutex argument file:logs/dd (Valid SSLMutex mechanisms are: `none',
default' )],這是Apache的一個Bug,只能使用default或者none.
上面的參數都是隨意寫的,可是個人多了須要請求的密碼,必須是4位,我設置爲test
3.自簽署證書 :
1>3650 是設置10年的證書有效期,基本夠用了
openssl x509 -req -in ca/ca-req.csr -out ca/ca-cert.pem -signkey ca/ca-key.pem -days 3650
2>生成ca-cert.cer證書,用於客戶端導入
openssl x509 -req -in ca/ca-req.csr -out ca/ca-cert.cer -signkey ca/ca-key.pem -days 3650
4.將證書導出成瀏覽器支持的.p12格式 : (不須要能夠省略)
openssl pkcs12 -export -clcerts -in ca/ca-cert.pem -inkey ca/ca-key.pem -out ca/ca.p12
密碼繼續設置爲test
製做服務器證書
經過keytool工具產生祕鑰、及證書請求文件,而後使用openssl上一步產生的ca根證書對證書請求進行簽證,
下面生成的文件都生成到C:\Users\xia\AppData\Local\VirtualStore\Program Files (x86)\Java\jdk1.6.0\bin目錄下了
Unix下面生成的文件都生成到:/openssl-0.9.8zc/server/目錄下邊
下面這兩步使用keytool工具
生成密鑰對
keytool -genkey -alias example -validity 3650 -keyalg RSA -keysize 1024 -keypass 123456 -storepass 123456 -keystore example.jks
生成證書請求
keytool -certreq -alias example -sigalg MD5withRSA -file example.csr -keypass 123456 -keystore example.jks -storepass 123456
後面的命令使用openssl
根據證書請求,生成服務器證書
openssl x509 -req -in server/example.csr -out server/example.pem -CA ca/ca-cert.pem -CAkey ca/ca-key.pem -days 3650 -set_serial 1
向Keystore中導入證書
切換回keytool工具
導入CA證書
keytool -import -v -trustcacerts -keypass 123456 -storepass 123456 -alias root -file C:\openssl-0.9.8zc\ca\ca-cert.pem -keystore C:\openssl-0.9.8zc\example.jks
AIX中命令以下:
keytool -import -v -trustcacerts -keypass 123456 -storepass 123456 -alias root -file /home/eteller/openssl/openssl-0.9.8zc/ca/ca-cert.pem -keystore /home/eteller/openssl/openssl-0.9.8zc/server/example.jks
導入服務器證書
keytool -import -v -trustcacerts -storepass 123456 -alias example -file C:\openssl-0.9.8zc\example.pem -keystore C:\openssl-0.9.8zc\example.jks
AIX中命令以下:
keytool -import -v -trustcacerts -storepass 123456 -alias example -file /home/eteller/openssl/openssl-0.9.8zc/server/example.pem -keystore /home/eteller/openssl/openssl-0.9.8zc/server/example.jks
查看Keystore文件內容
keytool -list -keystore C:\openssl-0.9.8zc\example.jks -storepass 123456
AIX中命令以下:
keytool -list -keystore /home/eteller/openssl/openssl-0.9.8zc/server/example.jks -storepass 123456
看到有2個證書,一個是根證書,一個是服務器證書,其中根證書是公鑰,服務器證書是私鑰
祕鑰庫文件:example.jks在ssl的配置中使用到。先把這個文件複製到以下位置:
C:\bea\user_projects\domains\base_domain即域的根目錄下。
AIX中命令以下:
cp example.jks /home/eteller/base_domain/
Weblogic 配置
打開ssl服務
設置keystore
密碼4個都是 以前申請生成example.jks的123456
設置SSL
這裏面Private Key Alias:是咱們服務器的別名,也就是以前設置的example,密碼仍是123456
須要把這個服務器名驗證設置爲NONE
屏蔽http訪問
設置完成以後,重啓Weblogic,能夠經過https://localhost:7002/ETellerbb/方式進行訪問,可是原有http://localhost:7001/ETellerbb/仍是能夠訪問,須要在web.xml下增長配置
<security-constraint>
<web-resource-collection >
<web-resource-name >SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
這樣訪問http時會自動跳轉到https
客戶端操做
導入CA證書
1、打開Internet選項-》選擇內容-》點擊證書
2、打開受信任的根證書頒發機構-》點擊「導入」按鈕
瀏覽器去掉地址不匹配警告
所有修改完畢以後,重啓瀏覽器