android - javax.net.ssl.SSLPeerUnverifiedException : No peer certificate error in eclipse

标签 android ssl wso2 ssl-certificate wso2-iot

在 android studio 代码中,我们使用 key 和信任,根据我们创建的 bks(emmtruststore.bks) 文件并粘贴到原始文件夹中的文档

我们在设备注册期间遇到以下错误

android studio 的错误日志

03-30 11:36:11.930 2200-2817/org.wso2.emm.agent I/System.out: URL: https://192.168.4.216:9443/dynamic-client-web/register

03-30 11:36:12.135 2200-2817/org.wso2.emm.agent E/ServerUtilities: Error occurred while sending 'Post' request due to failure of server connection
03-30 11:36:12.135 2200-2817/org.wso2.emm.agent E/DynamicClientManager: Failed to contact server
    org.wso2.emm.agent.proxy.IDPTokenManagerException: Error occurred while sending 'Post' request due to failure of server connection
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.sendPostRequest(ServerUtilities.java:325)
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.postData(ServerUtilities.java:151)
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:144)
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:132)
        at android.os.AsyncTask$2.call(AsyncTask.java:288)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)
     Caused by: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
        at com.android.org.conscrypt.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146)
        at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
        at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)
        at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
        at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.sendPostRequest(ServerUtilities.java:307)
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.postData(ServerUtilities.java:151) 
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:144) 
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:132) 
        at android.os.AsyncTask$2.call(AsyncTask.java:288) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
        at java.lang.Thread.run(Thread.java:841) 
03-30 11:36:12.135 2200-2200/org.wso2.emm.agent E/AuthenticationActivity: error occurred while retrieving client credentials

最佳答案

由于您是通过 HTTPS 访问 API,因此您的客户端必须拥有自己的信任库。为此,您可以使用 EMM 的 keystore 作为您的信任库。或者,您可以创建自己的信任库。

System.setProperty("javax.net.ssl.trustStore", "$EMM_HOME/repository/resources/security/wso2carbon.jks");  
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");  
System.setProperty("javax.net.ssl.trustStoreType", "JKS");

关于android - javax.net.ssl.SSLPeerUnverifiedException : No peer certificate error in eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36303409/

相关文章:

java - 使用 BottomBar 可以防止 fragment 打开?

python - 使用 python 脚本在 apache2 上不通过 SSL 显示图像

ssl - 将 CA 签名证书导入 JKS

android - 在 Android 中处理丰富动画的最佳方式

android - 显示多个排行榜

安全建议 : SSL and API access

google-chrome - Nginx 反向代理适用于 Safari 和 Firefox,但不适用于 Chrome

WSO2 API 管理器 : How do I log the fulle (http) SOAP response

java - WSO2 ESB 无法调用 ActiveMQ

android - 通过org.swinglabs:pdf-renderer不断获取gradle错误 “…APK was either not signed”