相关疑难解决方法(0)

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

我知道,关于这个问题有很多不同的问题和很多答案...但我无法理解......

我有:ubuntu-9.10-desktop-amd64 + NetBeans6.7.1从"关闭"安装.代表.我需要通过HTTPS连接到某个站点.为此我使用Apache的HttpClient.

从教程我读到:

"一旦正确安装了JSSE,通过SSL进行安全的HTTP通信
就像普通的HTTP通信一样简单." 还有一些例子:

HttpClient httpclient = new HttpClient();
GetMethod httpget = new GetMethod("https://www.verisign.com/"); 
try { 
  httpclient.executeMethod(httpget);
  System.out.println(httpget.getStatusLine());
} finally {
  httpget.releaseConnection();
}
Run Code Online (Sandbox Code Playgroud)

到现在为止,我写道:

HttpClient client = new HttpClient();

HttpMethod get = new GetMethod("https://mms.nw.ru");
//get.setDoAuthentication(true);

try {
    int status = client.executeMethod(get);
    System.out.println(status);

    BufferedInputStream is = new BufferedInputStream(get.getResponseBodyAsStream());
    int r=0;byte[] buf = new byte[10];
    while((r = is.read(buf)) > 0) {
        System.out.write(buf,0,r);
    }

} catch(Exception ex) {
    ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

结果我有一组错误:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable …
Run Code Online (Sandbox Code Playgroud)

java ssl https apache-commons-httpclient

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

数字证书:如何将.cer文件导入到.truststore文件中?

有没有人遇到他们必须处理.truststore文件的地方?并知道如何将.cer导入.truststore文件?

我不确定是否必须使用Java Keytool或Linux命令(例如openssl命令).

谢谢

digital-certificate truststore

85
推荐指数
3
解决办法
21万
查看次数

如何以编程方式创建新的KeyStore?

我正在尝试以编程方式在Java中创建一个新的密钥库.以下代码:

KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.setCertificateEntry("alias", cert);
Run Code Online (Sandbox Code Playgroud)

抛出未初始化的KeyStore异常.

java keystore

54
推荐指数
3
解决办法
7万
查看次数

如何在Rest-Assured java中使用证书进行HTTPS GET调用

如何使用Java中的Rest-Assured向需要证书的端点进行GET调用.我有证书作为.pem格式.在PEM文件中有证书和私钥.

java certificate rest-assured

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

Not able to connect to server through java code. Getting javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

I am trying to build a Test Automation Tool for REST API on AWS using rest-assured framework. I just tried with a simple HTTP POST and checking the output JSON body. But when I run that in Eclipse I get SSLHandshakeException. I did try to look into the issue and found it could be something related to server certificate (Received fatal alert: handshake_failure through SSLHandshakeException) but when I test it through POSTMAN it is running fine and …

java rest ssl sslhandshakeexception rest-assured

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