我在stackoverflow上关注了许多链接并尝试了许多解决方案,但它们都没有为我工作.我正在使用WSO2 API manager版本1.9.1.我正面临以下错误:
Exception in thread "main" javax.net.ssl.SSLPeerUnverifiedException: Host name 'XXXXXXXXX' does not match the certificate subject provided by the peer (CN=localhost, O=WSO2, L=Mountain View, ST=CA, C=US)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:465)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:395)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at com.java.pushNotifications.WSO2DemoClient.main(WSO2DemoClient.java:49)
Run Code Online (Sandbox Code Playgroud)
我开发了以下Java代码.请帮我解决这里出了什么问题.我需要连接不安全的方式,并允许连接到没有证书的 SSL站点.
public static void main(String[] args) throws ClientProtocolException, IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, …Run Code Online (Sandbox Code Playgroud) java ssl ssl-certificate apache-httpclient-4.x wso2-api-manager
我们需要在Google App Engine上实施双向SSL,我们使用JAX-WS向需要双向SSL身份验证的服务器发送Web服务请求.
我们如何为传出的Web服务请求设置双向SSL?
我们知道javax.net.ssl*在App Engine环境中禁止使用.
这是我们代码的一个例子:
@WebService(name="ListenerSoap", targetNamespace = "http://example.com/Listener.Wsdl")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface ListenerSoap {
@WebMethod(operationName = "Ping", action="http://example.com/Listener.Wsdl#Ping")
public void ping();
}
@WebServiceClient(name="Listener", targetNamespace="http://example.com/Listener.Wsdl", wsdlLocation = "https://example.com/Listener.asmx?WSDL")
public class Listener extends Service
{
public ListenerSoap getListenerSoap() {
return super.getPort(new QName("http://example.com/Listener.Wsdl",
"ListenerSoap"), ListenerSoap.class);
}
}
Run Code Online (Sandbox Code Playgroud)
以上代码的一个例子:
ListenerSoap soap = new Listener().getListenerSoap();
soap.ping();
Run Code Online (Sandbox Code Playgroud)
我想我们可以将DataStore中所需的密钥库或任何证书存储为二进制对象(尽管如何上传它们对我来说仍然是模糊的).
我们如何设置此Web服务使用双向SSL进行身份验证所需的必要值?
谢谢你的帮助
更新:
通过研究我已经看到这是如何在传统服务器上进行的(一个具有文件系统访问权限):
ListenerSoap soap = new Listener().getListenerSoap();
((BindingProvider) soap).getRequestContext().put("javax.net.ssl.keyStore", "client_cert.p12"
Run Code Online (Sandbox Code Playgroud)
但是,在这种方法中,client_cert.p12预计会在文件系统上.
此外,SSLSocketFactory,SSLContext,KeyManager,和 …
我正在编写一个访问远程服务器的例程.我连接的这个服务器需要相互身份验证,所以我必须提供一个密钥库,当我在它时,我也想建立一个适当的信任库.
我可以找到很多关于如何创建密钥库的教程,以及keytool让Apache HTTP客户端识别它的多种方法,但不是在Tomcat环境中将它存储在何处以便应用程序可以找到它.不知何故把它放在应用程序的war文件中对我来说似乎是一个坏主意.
同样,这不是允许Tomcat处理入站https连接 - 我有一个由我们的管理团队为此设置的反向代理.我正在创建需要相互身份验证的传出https连接,即接受自签名目标服务器证书,并提供我的服务器的自签名客户端证书.
您在哪里将实际的密钥库和信任库文件存储在Tomcat环境中以供Web应用程序使用?
我正在尝试使用Apache Client 4.5.5连接到我的Web服务器之一。
我正在尝试使用SSLContextBuilder,但现在似乎已弃用它,我不想使用已弃用的东西。
有人可以建议最新的处理无效认证的方法吗?
下面是我的代码,它工作正常,但是不建议使用SSLContext,SSLContextBuilder,loadTrustmaterial。
SSLContextBuilder sscb = new SSLContextBuilder();
sscb.loadTrustMaterial(null, new org.apache.http.conn.ssl.TrustSelfSignedStrategy());
SSLContext sslContext = sscb.build();
SSLConnectionSocketFactory sslSocketFactory =
new SSLConnectionSocketFactory(sslContext, new org.apache.http.conn.ssl.DefaultHostnameVerifier());
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.setSSLSocketFactory(sslSocketFactory)
.setConnectionManager(connectionMgr)
.build();
try {
HttpPost httppost = new HttpPost("myURL");
Run Code Online (Sandbox Code Playgroud)