Amazon Elastic Beanstalk HTTPS self-signed certificate 创建与上传

基于本机上以安装亚麻Amazon EB CLI的记录。EB CLI在Mac上比较推荐用 Homebrew    

brew install awsebcli

官网上也有用pip安装的选择,但是本机pip安装后的所有程序不知为何都需要重新手动设置PATH。WindowsLinuxVM上的安装官网上也有具体的说明,应该也是照搬即可。

亚麻说:“HTTPS is a must for any application that transmits user data or login information”.

正常情况下如果购买了域名应自带HTTPS证书,但如我买不起域名的孩纸只能一步步自给自足,自己动手来给HTTPS证书签名了。

创建、签署证书按照官网的说明走基本不会出错。搬运一下流程,大概是先在本机ssh到远程镜像上后,创建所需的秘钥以及公共证书:

eb ssh
openssl genrsa 2048 > privatekey.pem
openssl req -new -key privatekey.pem -out csr.pem 
cmd会要求输入一些信息,比如国家缩写、省名、市名等,这些都如实填写后,比较重要的是 Common Name:

"The fully qualified domain name for your web site. This must match the domain name that users see when they visit your site, otherwise certificate errors will be shown."

对于没有购买域名的本人来说,直接贴了Beanstalk app的URL(登陆AWS后, Services -> Elastic Beanstalk -> All applications下点击进入已经创建的app -> 面包屑导航里的URL: http://my-app-env.xxxxxxxxx.xx-xxxx-x.elasticbeanstalk.com/)

至于这样work不work,也只能以后才能知道了。

创建好后,签名:

openssl x509 -req -days 365 -in csr.pem -signkey privatekey.pem -out server.crt

这样创建出来的证书(server.crt)有365天的时效。

上传到IAM也很简单,在环境里(注意这里还是eb ssh后的环境)直接写:

aws iam upload-server-certificate --server-certificate-name elastic-beanstalk-x509 --certificate-body file://server.crt --private-key file://privatekey.pem

这里证书和秘钥路径需要保留 file:// 这个前缀。

到此,HTTPS证书签名、上传就成功了。(至于这是不是就能保证app与三方之间数据的传输,还有待考证)

猜你喜欢

转载自blog.csdn.net/weixin_36393382/article/details/80915048