我想通過Websphere Application Server訪問通過https託管的Web服務。 我正在使用以下方法進行https連接。如何導入帶有Java HttpsURLConnection的證書
HttpsURLConnection connection= (HttpsURLConnection) new URL(wcfUrl).openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setAllowUserInteraction(false);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("foo",userId);
connection.setRequestProperty("bar", pwd);
connection.setRequestProperty("Content-Type","application/xml");
connection.connect();
當我嘗試運行此代碼我碰到下面的錯誤 * com.ibm.jsse2.util.g:PKIX路徑建設失敗: java.security.cert.CertPathBuilderException:PKIXCertPathBuilderImpl不能建一個有效的證書路徑。內部原因是: java.security.cert.CertPathValidatorException: 由CN = GlobalSign根CA,OU = Root CA,O = GlobalSign nv-sa,C = BE頒發的證書不可信;內因是: java.security.cert.CertPathValidatorException:證書鏈接錯誤 * 我在本地服務器導入簽名證書之後(由於在這個環節http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Ftsec_sslretrievesignersport.html解釋)我是能夠連接到遠程服務器(其中該服務通過https部署)。 我可以在不導入簽署者證書的情況下通過java代碼做同樣的事情嗎?