问题一:osssdk调用EOS上传文件报错:返回结果无效,无法解析。
我使用的是osssdk,调用EOS。具体可以看这个文档:
https://help.aliyun.com/document_detail/2412601.html?spm=a2c4g.2412601.0.0.686e4484udqsaZ
sdk的版本是:
<dependency> <groupId>com.aliyun.oss</groupId> <artifactId>aliyun-sdk-oss</artifactId> <version>3.11.3</version> </dependency>
我确保的ak没有问题,使用的代码是文档提供的上传代码。
上传的时候就会报如下错误:
我尝试调用listObject或者listBucket都是没有问题的,单单就是上传putObject有问题。
参考回答:
根据你提供的错误信息,看起来是你的SDK版本与你的OSSSDK不兼容。你正在使用的AKS版本(1.0.17)与你的OSS SDK版本(3.11.3)不兼容。
解决这个问题的方法是,确保你的AKS版本与你的OSS SDK版本兼容。你可以查看OSS SDK的兼容性列表,看看哪个AKS版本与你的OSS SDK版本兼容。
另外,你也可以尝试更新你的AKS版本。你可以访问阿里云的OSS SDK页面,查看最新的AKS版本和兼容性信息。
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/559121
问题二:想问一下,从阿里OSS流式下载的PDF文件,无法被pdfbox读取。想问下这种应该怎么解决呢?
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key);
// 获取OSSObject实例
OssObject ossObject = client.getObject(getObjectRequest);
// 获取输入流
InputStream inputStream = ossObject.getObjectContent();
// 使用输入流进行后续操作,比如读取PDF文件等
PDDocument load = PDDocument.load(inputStream);
最后一行报错,显示Error: End-of-File, expected line
参考回答:
"End-of-File, expected line" 错误通常表示 PDF 文件格式不正确或被截断了,导致 PDFBox 无法正确解析文件。这可能是由于多种原因引起的,包括网络传输问题、OSS 服务问题或 PDF 文件本身的问题。
最重要的是排除文件和网络传输问题。如果确定问题不是由于这些因素引起的,那么可以考虑尝试不同的 PDF 处理库
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/553272
问题三:您好我使用阿里云oss上服务器后报错
本地使用的是http前缀 服务器是https 然后上传文件报错
请问这个怎么解决呢 ?
参考回答:
SSL异常通常是指在网络通信过程中出现的与SSL(安全套接层)相关的错误。服务器使用的是HTTPS,但是在OSS客户端配置中指定了HTTP URL。这可能导致客户端无法验证OSS服务器的身份,从而引发错误。请确保在客户端配置中使用正确的HTTPS URL。
您可以尝试以下方法:
检查服务器和客户端的SSL配置,确保使用了有效的证书和证书链。
检查网络环境,确保客户端和服务器之间的连接畅通无阻。
更新客户端的SSL库和驱动程序,以修复潜在的安全漏洞。
在客户端和服务器上启用日志记录,以便分析和定位具体的问题。
如果怀疑遭受了中间人攻击,可以使用SSL诊断工具(如OpenSSL的s_client命令行工具)来检查连接是否安全。
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/549439
问题四:通过阿里云的域名打开的网页报这个错误,打不开页面,但是通过iss部署可以打开,这是为什么,怎么解决
参考回答:
1、检查下文件是否已经上传到OSS
2、检查是否接入CDN,如果有的话,需要将CDN的地址做DNS解析,如果没有的话参考第三点
3、检查DNS是否解析到OSS
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/531613
问题五:紧急问题求助,生产环境都OK的,在另外一个客户现场报错了,提示SSL证书问题,连接超时?
SDK版本:3.16.3 JDK:OpenJDK1.8 异常信息: [ErrorCode]: SslException [RequestId]: Unknown
Connecting socket to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 with timeout 50000
Code: public static void main(String[] args) throws IOException { AliyunOSSUtils utils = new AliyunOSSUtils(); OSS oss = utils.init(); String path = utils.uploadPath(oss, "C:\home\issue_1686049594643.xlsx", "issue_1686049594643.xlsx", "ISSUE"); System.out.println(path); utils.destroy(oss); }
/** * 初始化构建客户端 */ public OSS init() { return new OSSClientBuilder().build("***", "***", "***"); } /** * 销毁客户端 */ public void destroy(OSS client) { if (null != client) { client.shutdown(); } } /** * 文件上传 * @param client * @param filePath * @param businessModel * @return * @throws IOException */ public String uploadPath(OSS client, String filePath, String fileName, String businessModel) throws IOException { String path = new StringBuilder(businessModel) .append("/") .append(fileName).toString(); PutObjectRequest putObjectRequest = new PutObjectRequest("**", path, new File(filePath)); client.putObject(putObjectRequest); return path; }
错误日志明细: 17:49:49.617 [main] DEBUG com.aliyun.oss - Loading mime types from file in the classpath: oss.mime.types 17:49:49.655 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default 17:49:49.662 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context 17:49:49.663 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:49.672 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 1 of 1024; total allocated: 1 of 1024] 17:49:49.673 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443 17:49:49.747 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 17:49:49.747 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 with timeout 50000 17:49:49.817 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2] 17:49:49.818 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] 17:49:49.818 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake 17:49:50.224 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection 17:49:50.225 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded 17:49:50.225 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:50.225 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Cancelling request execution 17:49:50.225 [main] WARN com.aliyun.oss - [Client]Unable to execute HTTP request: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown 17:49:50.225 [main] DEBUG com.aliyun.oss - Retrying on com.aliyun.oss.ClientException: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown 17:49:50.225 [main] DEBUG com.aliyun.oss - An retriable error request will be retried after 600(ms) with attempt times: 1 17:49:50.832 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default 17:49:50.832 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context 17:49:50.832 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:50.832 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 1][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 1 of 1024; total allocated: 1 of 1024] 17:49:50.832 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443 17:49:50.833 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 17:49:50.833 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 with timeout 50000 17:49:51.933 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2] 17:49:51.933 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] 17:49:51.933 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake 17:49:52.205 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-1: Shutdown connection 17:49:52.205 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded 17:49:52.206 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 1][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:52.206 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Cancelling request execution 17:49:52.206 [main] WARN com.aliyun.oss - [Client]Unable to execute HTTP request: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown 17:49:52.206 [main] DEBUG com.aliyun.oss - Retrying on com.aliyun.oss.ClientException: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown 17:49:52.206 [main] DEBUG com.aliyun.oss - An retriable error request will be retried after 1200(ms) with attempt times: 2 17:49:53.415 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default 17:49:53.416 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context 17:49:53.416 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:53.416 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 2][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 1 of 1024; total allocated: 1 of 1024] 17:49:53.416 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443 17:49:53.416 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 17:49:53.416 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 with timeout 50000 17:49:54.459 [idle_connection_reaper] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Closing expired connections 17:49:54.459 [idle_connection_reaper] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Closing connections idle longer than 60000 MILLISECONDS 17:49:54.473 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2] 17:49:54.473 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] 17:49:54.473 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake 17:49:56.638 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-2: Shutdown connection 17:49:56.638 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded 17:49:56.639 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 2][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:56.639 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Cancelling request execution 17:49:56.639 [main] WARN com.aliyun.oss - [Client]Unable to execute HTTP request: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown 17:49:56.639 [main] DEBUG com.aliyun.oss - Retrying on com.aliyun.oss.ClientException: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown 17:49:56.639 [main] DEBUG com.aliyun.oss - An retriable error request will be retried after 2400(ms) with attempt times: 3 17:49:59.053 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default 17:49:59.053 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context 17:49:59.053 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:59.053 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 3][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 1 of 1024; total allocated: 1 of 1024] 17:49:59.053 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443 17:49:59.054 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 17:49:59.054 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com/106.14.228.109:443 with timeout 50000 17:49:59.118 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2] 17:49:59.118 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] 17:49:59.118 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake 17:49:59.410 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-3: Shutdown connection 17:49:59.410 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded 17:49:59.410 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 3][route: {s}->https://msdai-dspot-prod.oss-cn-shanghai.aliyuncs.com:443][total available: 0; route allocated: 0 of 1024; total allocated: 0 of 1024] 17:49:59.410 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Cancelling request execution 17:49:59.410 [main] WARN com.aliyun.oss - [Client]Unable to execute HTTP request: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown Exception in thread "main" com.aliyun.oss.ClientException: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain [ErrorCode]: SslException [RequestId]: Unknown at com.aliyun.oss.common.utils.ExceptionFactory.createNetworkException(ExceptionFactory.java:74) at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:142) at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:149) at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:85) at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:134) at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:192) at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:153) at com.aliyun.oss.internal.OSSObjectOperation.writeObjectInternal(OSSObjectOperation.java:1195) at com.aliyun.oss.internal.OSSObjectOperation.putObject(OSSObjectOperation.java:130) at com.aliyun.oss.OSSClient.putObject(OSSClient.java:619) at com.oss.AliyunOSSUtils.uploadPath(AliyunOSSUtils.java:98) at com.oss.AliyunOSSUtils.main(AliyunOSSUtils.java:34) Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain at sun.security.ssl.Alerts.getSSLException(Alerts.java:198) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1967) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:331) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:325) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1688) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:226) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1082) at sun.security.ssl.Handshaker.process_record(Handshaker.java:1010) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1079) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1388) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1416) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1400) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:436) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:139) ... 10 more Caused by: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain at com.aliyun.oss.common.comm.DefaultServiceClient$CompositeX509TrustManager.checkServerTrusted(DefaultServiceClient.java:393) at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:1099) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1670) ... 28 more
参考回答:
这个问题可能是由于您的代码与阿里云OSS存储系统的SSL证书不匹配所导致的。您可以尝试更新您的SDK版本或使用更新的JDK来解决这个问题。同时,您也可以尝试手动安装正确的SSL证书,或者增加连接超时时间来解决这个问题。
以下是一些可能有用的步骤:
更新SDK版本或JDK:尝试使用最新的SDK版本或JDK来运行您的代码。这可能会解决您遇到的问题。
手动安装SSL证书:如果您知道正确的SSL证书,您可以尝试手动安装它。这可以解决与证书不匹配相关的问题。
增加连接超时时间:如果您的代码连接OSS存储系统的速度较慢,您可以尝试增加连接超时时间。您可以在代码中使用以下代码来设置连接超时时间:
java AliyunOSSUtils utils = new AliyunOSSUtils();
utils.setConnectionTimeout(10000); // 设置连接超时时间为10秒
OSS oss = utils.init(); 希望这些步骤能够帮助您解决这个问题。如果问题仍然存在,请提供更多的异常信息,以便我们更好地帮助您解决问题。
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/521540