在使用amazonS3的时候,当在 amazon ec2 上面运行 S3的时候,把配置的证书 修改为
使用默认的 amazon ec2的证书的时候,出现了一下异常
com.amazonaws.http.AmazonHttpClient executeHelper
INFO: Unable to execute HTTP request: hostname in certificate didn't match: <com.example.com.s3.amazonaws.com> != <*.s3.amazonaws.com> OR <*.s3.amazonaws.com> OR <s3.amazonaws.com>
javax.net.ssl.SSLException: hostname in certificate didn't match: <com.example..com.s3.amazonaws.com> != <*.s3.amazonaws.com> OR <*.s3.amazonaws.com> OR <s3.amazonaws.com>
从amazon 文档来看 只需要在构建 S3Client的时候,从
ClientConfiguration clientConfiguration = new ClientConfiguration();
AWSCredentials credentials = new ClasspathPropertiesFileCredentialsProvider().getCredentials();
AmazonS3Client s3Client = new AmazonS3Client(credentials,clientConfiguration);
修改为 AmazonS3Client s3Client = new AmazonS3Client();
s3Client.setConfiguration(clientConfiguration);
就应该可以啦;
但是为什么不可以呢?在amaoznS3 的源码里面发现 原来
可此时 为什么会出上面的错误呢?
原来 在 AmazonS3Client 的构造函数中,会利用传入的ClientConfiguration或者系统默认的ClientConfiguration创建AmazonHttpClient,并且设置AmazonHttpClient为disableStrictHostnameVerification(),而咱们显示设置clientConfiguration的时候
会重新创建AmazonHttpClient,并且没有显示的设置
AmazonHttpClient为disableStrictHostnameVerification(),
而设置disableStrictHostnameVerification() 没有提供外部函数, 只有在构造函数里面才能调用;
所以我们需要这样调用
credentials=new InstanceProfileCredentialsProvider().getCredentials();// 得到当前ec2 instance 的证书
s3Client = new AmazonS3Client(credentials, clientConfiguration);
disableStrictHostnameVerification()的作用就是
// Because of S3's virtual host style addressing, we need to change the
// default, strict hostname verification to be more lenient.
相关推荐
阿里云
系统环境:CentOS Linux release 7.6.1810 (Core) 起因:npm构建时报错 ... fatal: unable to access 'https://github.com/nhn/raphael.git/': Failed connect to github.com:443; Connection timed out npm
在Ubuntu操作系统中,Vim(Vi Improved)是一款强大的文本编辑器,因其高度可配置和高效操作而深受程序员和系统管理员喜爱。"vim config"指的是对Vim编辑器进行个性化设置的过程,以提升编辑效率和舒适度。...
### 解决Keil C51 编译器执行问题:“can't execute 'CKeilC51BINA51.EXE'.txt” 在使用Keil C51编译器的过程中,可能会遇到一个常见的错误提示:“can't execute 'CKeilC51BINA51.EXE'.txt”。这个问题通常出现在...
### Android错误解决:Conversion to Dalvik format failed: Unable to execute dex: Wrapper was not properly loaded first 在Android开发过程中,开发者可能会遇到多种类型的错误提示。其中,“Conversion to ...
在IT行业中,我们经常遇到各种错误,"failed to execute script"是其中之一,尤其在尝试运行Python脚本时。这个问题通常发生在使用Python的`py`或`exe`可执行文件时,尤其是在试图通过命令行传递参数时。让我们深入...
JAVA.NET.SOCKETEXCEPTION TOO MANY OPEN FILES解决方法 JAVA.NET.SOCKETEXCEPTION TOO MANY OPEN FILES错误是一种常见的网络编程错误,发生在Java应用程序中, especialmente 在 Linux 操作系统中。...
init:rcS post-stop process(1160) init:rcS post-stop process(923)
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project
然而,在使用`pyinstaller`将Python脚本打包成exe文件后,可能会遇到“Failed to execute script pyi_rth_certifi”这样的错误。本文将详细解释这个问题的原因,并提供解决此问题的方法。 首先,`pyinstaller`在...
Python 3.85 使用pyinstaller在win10 x64下打包的应用程序,在win10 x64下运行完全正常,但是在win7 x64下则报错。failed to execute script pyi_rth_ pyi_rth_xxx 解决方法
在<plugins></plugins>中添加 <groupId>org.apache.maven.plugins <artifactId>maven-compiler-plugin <version>3.8.1 <source>1.8 <target>1.8 </plugin>
AStyle_2.05.1_windows astyle_2.05.1_macosx astyle_2.05.1_linux 把bin\AStyle.exe 放到 "D:\program files\AStyle\bin\AStyle.exe" ...http://blog.csdn.net/gw_cs/article/details/7927735
在使用Maven构建Java项目时,可能会遇到这样一个错误:“Failed to execute goal on project …: Could not resolve dependencies for project …”。这个错误通常表明Maven在构建过程中遇到了依赖解析问题,无法...
### React Native错误:Failed to Execute aapt 解决方案 #### 一、问题概述 在React Native项目开发过程中,可能会遇到“Failed to execute aapt”这一错误。该错误通常发生在使用命令行工具(cmd)启动项目时,...
qt-sql-odbc-prog-example ==================== 作者:William.L 电子邮件: SlideShare: ://www.slideshare.net/wiliwe/ 目的 示例代码:###### Linux上Qt ODBC数据库访问的使用说明######
could not execute:bad executable format(win32 error 193) 下了一个实现MD5的代码,编译时没有错误,但是执行的时候却提示:could not execute:bad executable format(win32 error 193)
用于分包,解决 android 打包时报Unable to execute dex: method ID not in [0, 0xffff]: 65536
在精简pyinstaller打包后的exe时,出现 Failed to execute scripte app 问题。无法定位到具体问题。 使用命令 出现问题命令: pyinstaller -Fw app.py 然而,通过vscode运行,或者python app.py并没有报错,推测...