设为首页 收藏本站
查看: 562|回复: 0

[经验分享] nginx +location + https

[复制链接]

尚未签到

发表于 2018-11-8 11:51:55 | 显示全部楼层 |阅读模式
客户端  [root@localhost keyes]# openssl genrsa 2048 > siyao.keys   (创建私钥)
  Generating RSA private key, 2048 bit long modulus
  ...............................................................................+++
  .+++
  e is 65537 (0x10001)
  [root@localhost keyes]# chmod 400 siyao.keys   (给予最小权限)
  [root@localhost keyes]# openssl req -new -key siyao.keys -out siyao.csr  (创建证书办法请求)
  You are about to be asked to enter information that will be incorporated
  into your certificate request.
  What you are about to enter is what is called a Distinguished Name or a DN.
  There are quite a few fields but you can leave some blank
  For some fields there will be a default value,
  If you enter '.', the field will be left blank.
  -----
  Country Name (2 letter code) [XX]:CN    (国家)
  State or Province Name (full name) []:shanghai  (省份)
  Locality Name (eg, city) [Default City]:shanghai   (市区)
  Organization Name (eg, company) [Default Company Ltd]:boke  (公司名)
  Organizational Unit Name (eg, section) []:boke - cainiao  (部门)
  Common Name (eg, your name or your server's hostname) []:www.abc.com  (要加密的RUL)
  Email Address []:boke@boke.com  (邮箱)
  Please enter the following 'extra' attributes
  to be sent with your certificate request
  A challenge password []:     (这里不要写密码,CA哪里一会解不开密码,自签名。。)
  An optional company name []:  (这里也跳过)
  [root@localhost keyes]# ls
  siyao.csr  siyao.keys     (生成一份.csr的文件)
  [root@localhost keyes]# scp siyao.csr 192.168.1.115:/root   (在我使用scp传输文件时,碰到了问题,因为之前做过NAT。网关上
  把icmp阻塞了,并且用的策略是block return,所以返回一个目标不可到达的包给你。)
  ssh: connect to host 192.168.1.115 port 22: No route to host
  [root@localhost keyes]# scp siyao.csr 192.168.1.115:/root   (传过去了)
  The authenticity of host '192.168.1.115 (192.168.1.115)' can't be established.
  RSA key fingerprint is ce:73:07:c4:4c:f3:2b:1b:21:c7:92:31:27:53:be:cf.
  Are you sure you want to continue connecting (yes/no)? yes
  Warning: Permanently added '192.168.1.115' (RSA) to the list of known hosts.
  root@192.168.1.115's password:
  siyao.csr
  # CA端
  [root@localhost ~]# openssl genrsa -des3 -out ca.key 4096  (生成公私钥,做自签名)
  Generating RSA private key, 4096 bit long modulus
  ............................++
  .......................++
  e is 65537 (0x10001)
  Enter pass phrase for ca.key:                  (自签名密码要记住,一会自签名过程要用到)
  Verifying - Enter pass phrase for ca.key:
  [root@localhost ~]# ls
  anaconda-ks.cfg  ca.key  siyao.csr
  [root@localhost ~]# openssl req -new -x509 -days 365 -key ca.key -out ca.crt  (自签名)
  Enter pass phrase for ca.key:
  You are about to be asked to enter information that will be incorporated
  into your certificate request.
  What you are about to enter is what is called a Distinguished Name or a DN.
  There are quite a few fields but you can leave some blank
  For some fields there will be a default value,
  If you enter '.', the field will be left blank.
  -----
  Country Name (2 letter code) [XX]:CN
  State or Province Name (full name) []:shanghai
  Locality Name (eg, city) [Default City]:shanghai
  Organization Name (eg, company) [Default Company Ltd]:NSA
  Organizational Unit Name (eg, section) []:FBI
  Common Name (eg, your name or your server's hostname) []:www.boke.com
  Email Address []:
  [root@localhost ~]# ls
  anaconda-ks.cfg  ca.crt  ca.key  siyao.csr
  [root@localhost ~]# openssl x509 -req -days 365 -in siyao.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out siyao.crt  (
  给客户端颁发证书)
  Signature ok
  subject=/C=CN/ST=shanghai/L=shanghai/O=boke/OU=boke - cainiao/CN=www.abc.com/emailAddress=boke@boke.com
  Getting CA Private Key
  Enter pass phrase for ca.key:
  [root@localhost ~]# ls
  anaconda-ks.cfg  ca.crt  ca.key  siyao.crt  siyao.csr
  [root@localhost ~]# scp siyao.crt 192.168.1.3:/etc/pki/CA/keyes (回传给客户端)
  The authenticity of host '192.168.1.3 (192.168.1.3)' can't be established.
  RSA key fingerprint is bd:4d:15:99:19:a7:d7:fb:6e:0a:91:b0:b7:62:04:73.
  Are you sure you want to continue connecting (yes/no)? yes
  Warning: Permanently added '192.168.1.3' (RSA) to the list of known hosts.
  root@192.168.1.3's password:
  siyao.crt                                                                                           100% 1590     1.6KB/s
  00:00
  [root@localhost ~]# ls
  anaconda-ks.cfg  ca.crt  ca.key  siyao.crt  siyao.csr
  客户端keyes目下要有私钥,公钥,证书
  [root@localhost keyes]# ls
  siyao.crt  siyao.csr  siyao.keys
  [root@localhost keyes]# pwd
  /etc/pki/CA/keyes


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-632386-1-1.html 上篇帖子: nginx lua模块安装 让nginx支持lua-opsfq的博客 下篇帖子: Nginx FastCGI 原理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表