gpt4 book ai didi

java - com.ibm.jsse2.util.h : No trusted certificate found

转载 作者:行者123 更新时间:2023-12-01 17:42:58 28 4
gpt4 key购买 nike

在基于 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 类的实例中,调用以下方法

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

它的作用是将用户重定向到外部资源以进行授权。

总结一下这一切:

  1. 我们向 urlToGoTo 发送 GET 请求
  2. 然后该服务将我们重定向到使用 HTTPS 的资源(如果重要的话)

但是我们甚至看不到它,导致出现上面的异常。该请求根本没有执行。

我们已经安装了所需的证书(外部源、身份验证、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;
        }
}

关于java - com.ibm.jsse2.util.h : No trusted certificate found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58753963/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com