Java API 使用 AWS SDK 时出现 SSLHandshakeException

SSLHandshakeException while using AWS SDK for Java API

我正在使用 Java API 在 Amazon S3 中上传和下载文件。直到大约一周前,它一直运行良好,即使我没有触及代码,它也完全停止工作。我想知道是否有解决方案。谢谢!

下面是运行良好的代码:

AWSCredentials credentials = new BasicAWSCredentials(ACCESSKEYID, SECRETKEY);
AmazonS3Client s3client = new AmazonS3Client(credentials);
List<String> bucketList = new ArrayList<String>();
    for (Bucket bucket : s3client.listBuckets()) {
        System.out.println(bucket.getName());
    }

这是错误:

Apr 11, 2015 9:44:12 PM com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Unable to execute HTTP request: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
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(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1904)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:279)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:273)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1446)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:901)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:837)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1023)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:534)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:402)
at com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.connectSocket(SdkTLSSocketFactory.java:118)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:685)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:460)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:295)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3736)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3686)
at com.amazonaws.services.s3.AmazonS3Client.listBuckets(AmazonS3Client.java:688)
at com.amazonaws.services.s3.AmazonS3Client.listBuckets(AmazonS3Client.java:696)
at keymanager.service.AWSAPI.getBucketList(AWSAPI.java:130)
at keymanager.view.KeyManager.initializeBucketList(KeyManager.java:59)
at keymanager.view.KeyManager.connectButtonActionPerformed(KeyManager.java:626)
at keymanager.view.KeyManager.access00(KeyManager.java:22)
at keymanager.view.KeyManager.actionPerformed(KeyManager.java:425)

我做了一些研究,有些人认为问题可能出在权限上。但是,我认为我已尽我所能按照此处的说明进行操作:http://docs.aws.amazon.com/AWSToolkitEclipse/latest/GettingStartedGuide/tke_setup_creds.html#d0e387。伙计们,我真的很困。谢谢,我们将不胜感激!

我有同样的问题。解决方案原来是设备错误的日期。尝试更新您的设备日期。原因是 SSL 证书有 issuance/expiry 日期,正在根据您的设备日期进行验证。

我遇到过类似的问题。我的问题是我在 beans xml 文件中标记了代理配置,如下所示。

<bean id="clientConfiguration" class="com.amazonaws.ClientConfiguration"> <property name="proxyHost" value="proxy.server.com"/> <property name="proxyPort" value="8080"/> </bean>

但是忘记设置 属性 .

进入协议后开始工作