Maven 配置https的倉庫地址時,需要在jdk中導入證書
一、背景
在使用maven搭建CAS服務的時候,pom中配置了一個https的倉庫地址,但是從該倉庫下載依賴包的時候無法成功下載。日誌報錯。這是沒有安全證書造成的。
maven PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path
二、證書管理
一、查看證書庫中的證書列表
cd %JAVA_HOME%\jre\lib\security
keytool -list -V -keystore cacerts -storepass changeit
命名解釋:
-keystore cacerts 選擇證書庫 cacerts。注意在%JAVA_HOME%\jre\lib\security目錄,所以可以直接用cacerts。
-storepass changeit 設置證書庫需要密碼 changeit爲默認密碼
二、導入證書
keytool -keystore cacerts -importcert -alias nexussecureca -file D:/https-shibboleth.net-nexus.cer -storepass changeit
命名解釋:-alias nexussecureca 設置導入證書的別名爲nexussecureca
-file xxxxx 設置導入證書的文件路徑
三、刪除證書
keytool -delete -alias nexussecureca -keystore cacerts -storepass changeit