gpt4 book ai didi

java - AWS DynamoDbMapper 错误...由 : javax.net.ssl.SSLProtocolException 引起:

转载 作者:太空宇宙 更新时间:2023-11-03 13:37:34 25 4
gpt4 key购买 nike

我正在尝试从 AWS 实现 DynamoDBMapper,但当我尝试连接到 AWS 服务器时应用程序崩溃了。

首先,我在 Android Studio 模拟器上运行 Android 4.4.2,一切似乎都运行良好。那里没有问题。尽管如此,当我尝试在实际设备上运行时(在平板电脑上运行 4.4.2...不知道制造商),我收到以下错误:

Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x6bffcdf0: 
Failure in SSL library, usually a protocol error error:140740B5:SSL
routines:SSL23_CLIENT_HELLO:no ciphers available (external/openssl/ssl/s23_clnt.c:486 0x68474ce0:0x00000000)

这是完整的堆栈跟踪:

Caused by: com.amazonaws.AmazonClientException: Unable to execute HTTP request: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x6bffcdf0: Failure in SSL library, usually a protocol error error:140740B5:SSL routines:SSL23_CLIENT_HELLO:no ciphers available (external/openssl/ssl/s23_clnt.c:486 0x68474ce0:0x00000000)

com.amazonaws.http.AmazonHttpClient.executeHelper AmazonHttpClient.java:421
com.amazonaws.http.AmazonHttpClient.execute AmazonHttpClient.java:196
com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke AmazonDynamoDBClient.java:3257
com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.getItem AmazonDynamoDBClient.java:904
com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.load DynamoDBMapper.java:393
com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.load DynamoDBMapper.java:466
com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.load DynamoDBMapper.java:340
@@@@.@@@@@.@@@@$@@@@.doInBackground MainActivity.java:1259
@@@@.@@@@@.@@@@$@@@@.doInBackground MainActivity.java:1237
android.os.AsyncTask$2.call AsyncTask.java:288
java.util.concurrent.FutureTask.run FutureTask.java:237
... 4 more

其次是:

Caused by: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x6bffcdf0: Failure in SSL library, usually a protocol error error:140740B5:SSL routines:SSL23_CLIENT_HELLO:no ciphers available (external/openssl/ssl/s23_clnt.c:486 0x68474ce0:0x00000000)

com.android.org.conscrypt.NativeCrypto.SSL_do_handshake Native Method
com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake OpenSSLSocketImpl.java:406
com.android.okhttp.Connection.upgradeToTls Connection.java:146
com.android.okhttp.Connection.connect Connection.java:107
com.android.okhttp.internal.http.HttpEngine.connect HttpEngine.java:294
com.android.okhttp.internal.http.HttpEngine.sendSocketRequest HttpEngine.java:255
com.android.okhttp.internal.http.HttpEngine.sendRequest HttpEngine.java:206
com.android.okhttp.internal.http.HttpURLConnectionImpl.execute HttpURLConnectionImpl.java:345
com.android.okhttp.internal.http.HttpURLConnectionImpl.connect HttpURLConnectionImpl.java:89
com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream HttpURLConnectionImpl.java:197
com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream HttpsURLConnectionImpl.java:254
com.amazonaws.http.UrlHttpClient.writeContentToConnection UrlHttpClient.java:128
com.amazonaws.http.UrlHttpClient.execute UrlHttpClient.java:65
com.amazonaws.http.AmazonHttpClient.executeHelper AmazonHttpClient.java:353
... 14 more

这是我的源代码:

BasicAWSCredentials awsCredentials = new BasicAWSCredentials("abcdef12345","blahblahblah");
AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(awsCredentials);
DynamoDbMapper dbMapper = new DynamoDBMapper(dynamoDBClient);

//.... then eventually .....

AWSDriverNameTable awsDriverNameTable = dbMapper.load(AWSDriverNameTable.class, merchantID);

这是错误开始的最后一行代码。

现在,我查看了 SO 和一些搜索引擎,了解到一些 Android 设备回退到 SSL v3,而我尝试连接的服务器使用 TLS v1.0(访问 www.ssllabs。 com 并发现它确实使用了 TLS 1.0)。这是另一个 SO 问题,有人似乎已经解决了与此非常相似的问题:

How to disable SSLv3 in android for HttpsUrlConnection?

因此,如果这是导致问题的原因(需要删除 SSLv3),我该如何着手将 AmazonDynamoDbClient 配置为仅使用 TLS 1.0?我注意到您可以创建一个 ClientConfiguration 并使用:

clientConfiguration.getApacheHttpClientConfig().setSslSocketFactory(NoSSLv3SocketFactory);

并在 AmazonDynamoDbClient 构造函数中为其提供 awsCredentials。但是,它接受:

org.apache.http.conn.ssl.SSLSocketFactory

不是

javax.net.ssl.SSLSocketFactory

这是我提供的链接的答案中使用的内容(更不用说 Android Studio 通知我 org.apache.http.conn.ssl.SSLSocketFactory 已弃用)。

无论如何,我们将不胜感激。谢谢!

最佳答案

您可以使用 org.apache.http.conn.ssl.SSLConnectionSocketFactory 而不是 org.apache.http.conn.ssl.SSLSocketFactory

来自 SSLSocketFactory 的 JavaDoc (https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/ssl/SSLSocketFactory.html) -

Deprecated. (4.3) use SSLConnectionSocketFactory

关于java - AWS DynamoDbMapper 错误...由 : javax.net.ssl.SSLProtocolException 引起:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34736988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com