官網指導是最詳細的,此文僅針對關鍵步驟做描述。
一,配置證書
1, 使用 keytool($JAVA_HOME/bin/keytool)生成本地祕鑰庫文件(*.jks):
$JAVA_HOME/bin/keytool -genkeypair -keysize 2048 -alias jira -keyalg RSA -sigalg SHA256withRSA -keystore /opt/atlassian/ca/jira.jks
注:
1)*.jks文件不要放在安裝目錄,以免後續升級時被沖掉;
2)執行時要輸入 firt name and last name,即common name。要寫域名或者IP,比如: 192.168.100.101,jira.company.com;
3)執行時要輸入密碼,只能是字母和數字組合,記住了,後續要用到。
2, 生成證書籤名請求(*.csr):
$JAVA_HOME/bin/keytool -certreq -keyalg RSA -alias jira -file jira.csr -keystore /opt/atlassian/ca/jira.jks
注:執行時要輸入上一步設置的密碼。
3, 簽名(*.crt):
1)CA機構簽名:
將生成的 jira.csr 提交給CA機構簽名,CA會給你簽名後的證書 jira.crt 以及根證書或者中間證書:root.crt
2)自簽名:
生成密鑰和根證書:
openssl req -newkey rsa:2048 -nodes -keyout ca.key -x509 -days 365 -out ca.crt
自簽名:
openssl x509 -req -CA ca.crt -CAkey ca.key -in jira.csr -out jira.crt -days 365 -CAcreateserial
檢查簽名:
openssl verify -verbose -CAfile ca.crt jira.crt
5, 導入根證書、簽名的證書至本地祕鑰庫:
$JAVA_HOME/bin/keytool -importcert -alias rootCA -keystore /opt/atlassian/ca/jira.jks -trustcacerts -file ca.crt
$JAVA_HOME/bin/keytool -importcert -alias jira -keystore /opt/atlassian/ca/jira.jks -file jira.crt
檢查導入證書:
$JAVA_HOME/bin/keytool -list -alias jira -keystore /opt/atlassian/ca/jira.jks
二、配置JIRA服務
1,備份<Jira_INSTALL>/conf/server.xml
2,配置https連接選項:
編輯<Jira_INSTALL>/conf/server.xml,增加如下:
<Connector port="8443" maxHttpHeaderSize="8192" relaxedPathChars="[]|" relaxedQueryChars="[]|{}^\`"<>"
maxThreads="150" minSpareThreads="25"
protocol="org.apache.coyote.http11.Http11NioProtocol"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" useBodyEncodingForURI="true" URIEncoding="UTF-8"
sslProtocol="TLSv1.2" sslEnabledProtocols="TLSv1.2,TLSv1.3" SSLEnabled="true"
keyAlias="jira" keystoreFile="/opt/atlassian/ca/jira.jks" keystorePass="xxx" keystoreType="JKS"/>
注:
1)如果JIRA是老版本升級的,那沒有這個參數會啓動不起來,一定要加上:relaxedQueryChars="[]|{}^\`"<>"
2)如果https端口不是8443,修改了端口,http裏的對應也要改:
3,配置http自動重定向https頁面:
編輯<Jira_INSTALL>/atlassian-jira/WEB-INF/web.xml,在
</web-app>前增加如下:
<security-constraint>
<web-resource-collection>
<web-resource-name>all-except-attachments</web-resource-name>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspa</url-pattern>
<url-pattern>/browse/*</url-pattern>
<url-pattern>/issues/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
三、重啓JIRA
使用原來的地址訪問,會自動跳到https的8443端口。