Tag: ssl certificate

信任Java Playframework 2.2中的所有SSL证书

我试图在Play框架中调用Web服务(具有自签名SSL证书)使用以下函数: public static play.libs.F.Promise webcall() { String feedUrl = “https://10.0.1.1/client/api”; final play.libs.F.Promise resultPromise = WS.url(feedUrl).get().map( new Function() { public Result apply(WS.Response response) { return ok(“Feed title:” + response.asJson().findPath(“title”).toString()); } } ); return resultPromise; } 它在日志中抛出以下错误, [error] play – Cannot invoke the action, eventually got an error: java.net.ConnectException: General SSLEngine problem to https://10.0.1.1/client/api [error] application – […]

使用Axis2附加客户端证书?

是否可以轻松地将客户端证书附加到使用wsdl2java生成的Axis2存根? 我需要在每个请求的基础上动态更改客户端证书,因此只需将其存储在密钥库中就不适用于我们的情况。 我已经找到了非SOAP调用的示例,但找不到与使用Axis客户端存根相关的任何内容。 尝试破解XML for SOAP调用是一个选项,我猜,albiet是一个痛苦的选择! 呻吟!

如何检索不受信任的SSL服务器证书以便查看和信任它?

我的问题: 我想连接到服务器(不限于HTTPS协议 – 可能是LDAP-over-SSL,可能是SMTPS,可能是IMAPS等),可能正在使用Java默认不信任的证书(因为它们是自签名)。 所需的工作流程是尝试连接,检索证书信息,将其呈现给用户,如果他接受,则将其添加到信任库,以便将其信任。 我被困在检索证书。 我有代码(请参阅post的末尾),我已经从这里和从有关java SSL的问题的答案所指向的站点进行了抄袭。 代码只是创建一个SSLSocket ,启动SSL握手,并向SSL会话询问Certificate[] 。 当我使用已经可信任的证书连接到服务器时,代码工作正常。 但是当我使用自签名证书连接到服务器时,我会得到通常的: Exception in thread “main” javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Unknown Source) at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) [etc] 如果我使用-Djavax.net.debug=all运行,我看到JVM确实检索了自签名证书,但是在到达返回证书之前,它会破坏连接以使用不受信任的证书。 看起来像鸡蛋问题。 它不会让我看到证书,因为它们不受信任。 但我需要看到证书能够将它们添加到信任库,以便它们可信。 你怎么突破这个? 例如,如果我将程序运行为: […]

将SSL证书导入Eclipse

如何将java创建的SSL证书导入Eclipse中的项目?

如何在Java中以编程方式检查SSL证书到期日期

我需要从Java网站上的SSL证书中提取到期日期,应该支持可信和自签名证书,例如:1.trusted https://github.com 2.self-signed https://mms.nw .RU / 我已经将一些代码复制为: import java.net.URL; import java.security.SecureRandom; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLTest { public static void main(String [] args) throws Exception { // configure the SSLContext with a TrustManager SSLContext ctx = SSLContext.getInstance(“TLS”); […]

Keytool创建受信任的自签名证书

我正在尝试使用(java)keytool创建自签名证书,但是当我尝试使用它时,我得到以下exception(请参阅底部的整个exception)。 … Caused by: sun.security.validator.ValidatorException: No trusted certificate found at sun.security.validator.SimpleValidator.buildTrustedChain(SimpleValidator.java:304) at sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:107) at sun.security.validator.Validator.validate(Validator.java:203) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172) at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:841) … 22 more 我知道我可以用这段代码绕过这个: import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; HostnameVerifier hv = new HostnameVerifier() { public boolean verify(String urlHostName, SSLSession session) { System.out.println(“Warning: URL Host: ” + urlHostName + ” vs. ” + […]

使用java代码将证书添加到密钥库

我正在尝试使用服务器的.cer证书文件建立https连接。 我可以使用浏览器手动获取证书文件,并使用keytool将其放入密钥库。 然后,我可以使用java代码访问密钥库,获取我添加到密钥库的证书并连接到服务器。 我现在想要实现获取证书文件并使用java代码将其添加到我的密钥库并且不使用keytool或浏览器来获取证书的过程。 有人可以告诉我如何处理这个以及我需要做什么?

“无法找到所请求目标的有效证书路径”,但浏览器表示没问题

我正在开发一个Java应用程序,它连接到https://ut.eurodw.eu/ (欧洲Datawarehouse的测试环境)中公开的SOAP服务。 我正在开发我的开发机器,最近用Windows 8.1重新格式化了。 今天,我尝试通过SOAP从我的程序向他们发送创建请求,并收到此错误: Caused by: javax.xml.ws.WebServiceException: Could not send Message. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146) at com.sun.proxy.$Proxy110.createDeal(Unknown Source) at it.csttech.edwin.services.spring.EdwinServiceImpl.createDeal(EdwinServiceImpl.java:102) at it.csttech.edwin.consumercredit.data.managers.spring.DealManagerImpl.createEdCode(DealManagerImpl.java:319) … 77 more Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking https://ut.eurodw.eu/edservices/2.2/DealService.svc: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at […]

在Java中请求URL时忽略证书错误

我正在尝试打印一个URL(根本没有涉及浏览器),但URL目前正在抛出以下内容: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 我使用JEditorPane的setPage方法调用URL,该方法仅将URL作为参数。 假设我无法更改任何服务器端,我仍然需要访问此资源,我将如何忽略证书错误(或其他让我达到目标的东西)? 通过浏览器访问此URL告诉我该网站不受信任,并询问我是否要继续。

HTTPClient-1.4.2:自定义SSL上下文示例所需的说明

这是来自HttpClient-4.x文档的自定义SSL上下文的示例: http : //hc.apache.org/httpcomponents-client-ga/examples.html 注意:为简洁起见,删除注释。 package org.apache.http.examples.client; import java.io.File; import java.io.FileInputStream; import java.security.KeyStore; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; /** * This example demonstrates how to create secure connections with a custom SSL * context. */ public class ClientCustomSSL { public final static void main(String[] args) throws […]