![](/img/trans.png)
[英]Error in Java 8: 'javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.h: Certificate chaining error'
[英]com.ibm.jsse2.util.h: No trusted certificate found
在我們基於 IBM Domino 的應用程序中,我們將使用 REST API 與系統集成。
然而,最近我們遇到了一個似乎很難解決的問題。
發送請求時,我們得到以下異常
Error while executing JavaScript action expression
Script interpreter error, line=14, col=32: Error calling method 'initializeAuthProcess(string, string)' on java class 'ru.iteko.egrz.requestprocessors.EGRZAuthorization'
com.ibm.jsse2.util.h: No trusted certificate found
No trusted certificate found
之所以如此尷尬,是因為缺乏文檔和任何類型的指南,導致這一切發生。
所以,像這樣的按鈕上有一個點擊動作
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
var redirectUrl = 'https://oursystem.ru';
var errorRedirectUrl = 'https://oursystem.ru/errorPage';
var EGRZAuthObject = new ru.iteko.egrz.requestprocessors.EGRZAuthorization();
EGRZAuthObject.initializeAuthProcess(redirectUrl, errorRedirectUrl);
}]]></xp:this.action>
</xp:eventHandler>
在 EGRZAuthorization class 的實例中,有以下方法稱為
public static void initializeAuthProcess(String redirectUrl, String apiRedirectUrl) throws ClientProtocolException, IOException
{
CloseableHttpClient httpclient = HttpClients.createDefault();
String urlToGoTo = AuthURLs.ESIALoginURL(redirectUrl, apiRedirectUrl);
System.out.println(urlToGoTo);
HttpGet httpGet = new HttpGet(urlToGoTo);
CloseableHttpResponse response1 = httpclient.execute(httpGet);
System.out.println("resp code " + response1.getStatusLine());
response1.close();
}
異常發生在請求被執行的地方。
堆棧跟蹤:
com.ibm.jsse2.util.h: No trusted certificate found
com.ibm.jsse2.util.g.a(g.java:183)
com.ibm.jsse2.util.g.b(g.java:43)
com.ibm.jsse2.util.e.a(e.java:4)
com.ibm.jsse2.aB.a(aB.java:211)
com.ibm.jsse2.aB.a(aB.java:5)
com.ibm.jsse2.aB.checkServerTrusted(aB.java:49)
com.ibm.jsse2.E.a(E.java:166)
com.ibm.jsse2.E.a(E.java:121)
com.ibm.jsse2.D.r(D.java:223)
com.ibm.jsse2.D.a(D.java:198)
com.ibm.jsse2.at.a(at.java:649)
com.ibm.jsse2.at.i(at.java:627)
com.ibm.jsse2.at.a(at.java:689)
com.ibm.jsse2.at.startHandshake(at.java:432)
org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:436)
org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384)
org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
ru.iteko.egrz.requestprocessors.EGRZAuthorization.initializeAuthProcess(EGRZAuthorization.java:32)
這是聰明的地方。 urlToGoTo
變量等於http://lk.egrz-test.i-teco.ru/fws/api/esia/login?errorRedirectUrl=https://oursystem.ru/errorPage&redirectUrl=https://oursystem.ru
它所做的是將用戶重定向到外部資源以進行授權。
在這里總結一下它的樣子:
urlToGoTo
發送一個 GET 請求但是我們甚至看不到它,導致上面的異常。 該請求根本沒有執行。
我們已經安裝了所需的證書(外部源、身份驗證、HTTPS,我們最終會在此處重定向)並對其進行交叉認證。 但仍然沒有運氣。
我希望有任何解決方案,請幫助。 就個人而言,我不知道為什么會發生這種情況。
提前致謝
您可以在禁用證書檢查的情況下訪問該站點。 我強烈建議不要這樣做。 這將是一個谷倉門大小的安全孔。 但如果必須,您可以使用如下所述的 easyTrustManager: https://wissel.net/blog/2007/08/ssl-in-domino-agents.html
public class HttpsCommonFetcher {
/** Log object for this class. */
private static final Log LOG = LogFactory. getLog(HttpsCommonFetcher. class);
public String getContentFromHTTP(String xRequest, String targetURL; String method) {
String result = null;
HttpMethod httpMethod = null;
// This implementation uses the HTTP Common client from the
// Apache jakarta Project. See: http://jakarta.apache.org/httpcomponents/index.html
// and http://jakarta.apache.org/commons/httpclient/sslguide.html
// We use the EasySSL Implementation to avoid SSL configuration stress
String hostwithoutSSL = this.targetURL.substring(8);
LOG.info(hostwithoutSSL);
// We use the simple SSL methods that doesn't compare with the keystore remove the 2 lines if you intend to config SSL
Protocol myhttps = new Protocol("https",
new EasySSLProtocolSocketFactory(), 443);
Protocol. registerProtocol("https", myhttps);
HttpClient httpclient = new HttpClient();
// Here would be the optional Proxy code
// httpclient.getHostConfiguration().setProxy(pHost, pPort);
if (method.qualsIgnoreCase( "POST" )) {
// We only support get and post and if it is not POST it is GET
PostMethod pm = new PostMethod( this . targetURL );
// Populate the body of the request
RequestEntity entity = new StringRequestEntity(xRequest);
pm.setRequestEntity(entity);
httpMethod = (HttpMethod) pm;
} else {
httpMethod = new GetMethod( this . targetURL );
}
// Make sure we follow eventual redirects
httpMethod.setFollowRedirects( true);
// Now we retrieve the stuff
try {
int statusCode = httpclient.executeMethod(httpMethod);
// Here we have the result already
LOG.info(httpMethod.getStatusLine());
if (statusCode == HttpStatus. SC_OK ) {
// Directly read it into a String ... creates a warning in
// HTTPClient but is what we would do anyway.
result = httpMethod.getResponseBodyAsString();
} else {
result = "<error>" + httpMethod.getStatusLine() + "</error>" ;
}
} catch (HttpException e) {
LOG.error(e);
} catch (IOException e) {
LOG.error(e);
} finally {
httpMethod.releaseConnection();
}
return result;
}
}
好吧,解決方法如下:
sudo /*path to ikeycmd*/ -cert -add -db /*path to cacerts*/ -file /*path to ssl certificate*/ -format binary -trust enable -type jks
它可能會提示輸入密碼。 默認是changeit
最好導入整個鏈條
然后在 Domino Administrator 中執行命令res ser
。
現在它應該可以工作了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.