Android mobilesdk应用上的SSLHandshakeException

2020-09-22 14:14发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨,尝试在模拟器上使用b2c变体启动android应用时遇到错误。 该应用程序不会获取任何数据,并且在我单击任何位置时都会一直显示异常。

以下是堆栈跟踪的一部分:

10-04 14:02:41.222 2352-3613/? E/DG.WV:无法与预配置服务器通信。 javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。 com.android.okhttp.Connection.connectTls(Connection.java:235)上com.android.okhttp.Connection.connectTls(Connection.java:235)上的com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(:com.google.android.gms:350)。 com.android.okhttp.Connection.connect(Connection.java:172)的com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)的okhttp.Connection.connectSocket(Connection.java:199) .okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130)在com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)在com.android.okhttp.internal.http.HttpEngine.sendRequest( com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)处com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)处的HttpEngine.java:246) .android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)位于com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsU RL.Connection.java:218)位于com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)位于ojq.a(:com.google.android.gms:71),位于ojq.a(:com.google .android.gms:53)位于omr.run(:com.google.android.gms:1059),原因:java.security.cert.CertificateException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。 com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:563)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:444)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive (TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)在com.android。 com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)上的org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)在android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java: 94),位于com.google.android.gms.org.conscrypt.Platform的java.lang.reflect.Method.invoke(Native Method),位于android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)。 com.goog上的checkTrusted(:com.google.android.gms:232) le.android.gms.org.conscrypt.Platform.checkServerTrusted(:com.google.android.gms:255)位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(:com.google.android.gms :588),位于com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(本地方法),位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(:com.google.android.gms:346 )com.android.okhttp.Connection.connectTls(Connection.java:235)com.android.okhttp.Connection.connectSocket(Connection.java:199)com.android.okhttp.Connection.connect(Connection.java: 172),位于com.android.okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130),位于com.android.okhttp.internal.http.HttpEngine的com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)。 com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)的连接(com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)的connect(HttpEngine.java:329) 在com.android.ok com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)上的com.android.okhttp.internal.huc.DelegatingHttpsURLConnection上的http.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)。 com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)的getOutputStream(DelegatingHttpsURLConnection.java:218)在ojq.a(:com)的ojq.a(:com.google.android.gms:71) .google.android.gms:53)位于omr.run(:com.google.android.gms:1059)造成原因:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。 com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:563)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:444)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive (TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)在com.android。 com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)上的org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)在android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java: 94),位于com.google.android.gms.org.conscrypt.Platform的java.lang.reflect.Method.invoke(Native Method),位于android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)。 com.goog上的checkTrusted(:com.google.android.gms:232) le.android.gms.org.conscrypt.Platform.checkServerTrusted(:com.google.android.gms:255)位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(:com.google.android.gms :588),位于com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(本地方法),位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(:com.google.android.gms:346 )com.android.okhttp.Connection.connectTls(Connection.java:235)com.android.okhttp.Connection.connectSocket(Connection.java:199)com.android.okhttp.Connection.connect(Connection.java: 172),位于com.android.okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130),位于com.android.okhttp.internal.http.HttpEngine的com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)。 com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)的连接(com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)的connect(HttpEngine.java:329) 在com.android.ok com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)上的com.android.okhttp.internal.huc.DelegatingHttpsURLConnection上的http.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)。 com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)的getOutputStream(DelegatingHttpsURLConnection.java:218)在ojq.a(:com)的ojq.a(:com.google.android.gms:71) .omr.run(:com.google.android.gms:1059)的.google.android.gms:53)

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨,尝试在模拟器上使用b2c变体启动android应用时遇到错误。 该应用程序不会获取任何数据,并且在我单击任何位置时都会一直显示异常。

以下是堆栈跟踪的一部分:

10-04 14:02:41.222 2352-3613/? E/DG.WV:无法与预配置服务器通信。 javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。 com.android.okhttp.Connection.connectTls(Connection.java:235)上com.android.okhttp.Connection.connectTls(Connection.java:235)上的com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(:com.google.android.gms:350)。 com.android.okhttp.Connection.connect(Connection.java:172)的com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)的okhttp.Connection.connectSocket(Connection.java:199) .okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130)在com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)在com.android.okhttp.internal.http.HttpEngine.sendRequest( com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)处com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)处的HttpEngine.java:246) .android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)位于com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsU RL.Connection.java:218)位于com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)位于ojq.a(:com.google.android.gms:71),位于ojq.a(:com.google .android.gms:53)位于omr.run(:com.google.android.gms:1059),原因:java.security.cert.CertificateException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。 com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:563)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:444)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive (TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)在com.android。 com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)上的org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)在android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java: 94),位于com.google.android.gms.org.conscrypt.Platform的java.lang.reflect.Method.invoke(Native Method),位于android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)。 com.goog上的checkTrusted(:com.google.android.gms:232) le.android.gms.org.conscrypt.Platform.checkServerTrusted(:com.google.android.gms:255)位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(:com.google.android.gms :588),位于com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(本地方法),位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(:com.google.android.gms:346 )com.android.okhttp.Connection.connectTls(Connection.java:235)com.android.okhttp.Connection.connectSocket(Connection.java:199)com.android.okhttp.Connection.connect(Connection.java: 172),位于com.android.okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130),位于com.android.okhttp.internal.http.HttpEngine的com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)。 com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)的连接(com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)的connect(HttpEngine.java:329) 在com.android.ok com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)上的com.android.okhttp.internal.huc.DelegatingHttpsURLConnection上的http.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)。 com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)的getOutputStream(DelegatingHttpsURLConnection.java:218)在ojq.a(:com)的ojq.a(:com.google.android.gms:71) .google.android.gms:53)位于omr.run(:com.google.android.gms:1059)造成原因:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。 com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:563)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:444)com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive (TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:508)在com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)在com.android。 com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)上的org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)在android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java: 94),位于com.google.android.gms.org.conscrypt.Platform的java.lang.reflect.Method.invoke(Native Method),位于android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)。 com.goog上的checkTrusted(:com.google.android.gms:232) le.android.gms.org.conscrypt.Platform.checkServerTrusted(:com.google.android.gms:255)位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(:com.google.android.gms :588),位于com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(本地方法),位于com.google.android.gms.org.conscrypt.OpenSSLSocketImpl.startHandshake(:com.google.android.gms:346 )com.android.okhttp.Connection.connectTls(Connection.java:235)com.android.okhttp.Connection.connectSocket(Connection.java:199)com.android.okhttp.Connection.connect(Connection.java: 172),位于com.android.okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130),位于com.android.okhttp.internal.http.HttpEngine的com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)。 com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)的连接(com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)的connect(HttpEngine.java:329) 在com.android.ok com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)上的com.android.okhttp.internal.huc.DelegatingHttpsURLConnection上的http.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)。 com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)的getOutputStream(DelegatingHttpsURLConnection.java:218)在ojq.a(:com)的ojq.a(:com.google.android.gms:71) .omr.run(:com.google.android.gms:1059)的.google.android.gms:53)

付费偷看设置
发送
2条回答
木偶小白
1楼-- · 2020-09-22 14:57

似乎

中存在某种OOTB错误
  hybris-Mobile-Apps-SDK-Android \ yCommerceApp \ src\ com \ hybris \ mobile \ app \ commerce \ CommerceApplicationBase.java
  

没有传递 SSLSocketFactory HostnameVerifier 替代文字

为了解决此问题,我们实现了 com.hybris.mobile.lib.commerce.helper.SSLHelper 替代文本

如下所示

 包com.ccelera.networking.utils;
 
  导入android.util.Log;
 
  导入com.hybris.mobile.lib.commerce.helper.SSLHelper;
 
  导入java.security.KeyManagementException;
  导入java.security.NoSuchAlgorithmException;
  导入java.security.SecureRandom;
  导入java.security.cert.CertificateException;
  导入java.security.cert.X509Certificate;
 
  导入javax.net.ssl.HostnameVerifier;
  导入javax.net.ssl.KeyManager;
  导入javax.net.ssl.SSLContext;
  导入javax.net.ssl.SSLSession;
  导入javax.net.ssl.SSLSocketFactory;
  导入javax.net.ssl.TrustManager;
  导入javax.net.ssl.X509TrustManager;
 
  公共类SelfSignedSSLHelperSyncService实现SSLHelper {
 
      私有静态SSLSocketFactory sslSocketFactory;
 
      @Override
      公共SSLSocketFactory getSSLSocketFactory(){
          返回getSocketFactory();
      }
 
      @Override
      public HostnameVerifier getHostnameVerifier(){
          返回新的HostnameVerifier(){
              @Override
              public boolean verify(String s,SSLSession sslSession){
                  返回true;
              }
          };
      }
 
    /**
       *返回一个接受所有服务器证书的SSL Factory实例。
       * 
 SSLSocket袜子=
       *(SSLSocket)getSocketFactory.createSocket(host,443);  
* @return SSL特定的套接字工厂。 * @url http://www.java2s.com/Code/Android/Network/ReturnsaSSLFactoryinstancethatacceptsallservercertificates.htm **/ 公共静态最终SSLSocketFactory getSocketFactory() { 如果(sslSocketFactory == null){ 尝试{ TrustManager tm =新的X509TrustManager(){ 公共无效checkClientTrusted(X509Certificate []链,字符串authType)抛出CertificateException { } 公共无效checkServerTrusted(X509Certificate []链,字符串authType)抛出CertificateException { } 公开的X509Certificate [] getAcceptedIssuers(){ 返回null; } }; SSLContext context = SSLContext.getInstance(" TLSv1"); context.init(new KeyManager [0],new TrustManager [] {tm},new SecureRandom()); sslSocketFactory =(SSLSocketFactory)context.getSocketFactory(); } catch(KeyManagementException e){ Log.e(" SSL","不支持SSL算法-" + e.getMessage()); } catch(NoSuchAlgorithmException e){ Log.e(" SSL","设置朴素密钥管理时的异常-" + e.getMessage()); } } 返回sslSocketFactory; } }
大道至简
2楼-- · 2020-09-22 15:06

你好,

您找到答案了吗? 我遇到了同样的错误。

致谢,

一周热门 更多>