小编Oli*_*hll的帖子

Apache HTTPClient SSLPeerUnverifiedException

使用Apache HttpClient 4.2.1.使用从基于表单的登录示例复制的代码

http://hc.apache.org/httpcomponents-client-ga/examples.html

访问受SSL保护的登录表单时出现异常:

Getting library items from https://appserver.gtportalbase.com/agileBase/AppController.servlet?return=blank
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
Closing http connection
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:572)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
Run Code Online (Sandbox Code Playgroud)

据我所知,证书很好(参见堆栈跟踪之前的URL),没有过期 - 浏览器不会抱怨.

我已经尝试将证书导入我的密钥库了

如何使用Apache HttpClient处理无效的SSL证书?

没有变化.我相信你可以创建一个自定义SSLContext来强制Java忽略错误,但我宁愿修复根本原因,因为我不想打开任何安全漏洞.

有任何想法吗?

java ssl apache-httpclient-4.x

14
推荐指数
1
解决办法
2万
查看次数

如何在Java中获得英国夏季偏移量(BST)

在英国,我想从UTC/GMT获得当前的偏差.目前偏移是1小时,但似乎无法找到这个.

    TimeZone timeZone = TimeZone.getDefault();
    logger.debug("Timezone ID is '" + timeZone.getID() + "'");
    if (timeZone.getID().equals("GMT")) {
        timeZone = TimeZone.getTimeZone("Europe/London");
        logger.debug("New timezone is '" + timeZone.getID() + "'");
    }
    Long eventDateMillis = Long.parseLong(eventDateValue.getKeyValue());
    int timezoneOffset = timeZone.getOffset(eventDateMillis);
    logger.debug("Offset for " + eventDateValue + "(" + eventDateMillis + ") using timezone " + timeZone.getDisplayName() + " is " + timezoneOffset);
Run Code Online (Sandbox Code Playgroud)

返回调试输出

Wed 2012/09/19 16:38:19.503|Debug|DataManagement|Timezone ID is 'GMT'
Wed 2012/09/19 16:38:19.503|Debug|DataManagement|New timezone is 'GMT'
Wed 2012/09/19 16:38:19.557|Debug|DataManagement|Offset for 18 Sep 2012 09:00(1347958800000) …
Run Code Online (Sandbox Code Playgroud)

java timezone

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×2

apache-httpclient-4.x ×1

ssl ×1

timezone ×1