apache、nginx配置openssl自签名证书
1、生成私钥
生成rsa私钥,des3算法,2048位强度。server.key是秘钥文件名,需要提供一个至少4位的密码。
[root@localhost ~]# openssl genrsa -des3 -out server.key 2048
Generating RSA private key, 2048 bit long modulus
........................................................+++
...................................+++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
2、生成csr(证书签名请求)
创建csr申请签名请求文件,然后发送给证书颁发机构(费用高)、或者实现自签名。
[root@localhost ~]# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.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) []:GuangDong
Locality Name (eg, city) [Default City]:ShenZhen
Organization Name (eg, company) [Default Company Ltd]:OPS
Organizational Unit Name (eg, section) []:OPS
Common Name (eg, your name or your server's hostname) []:www.test.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
3、删除私钥的密码
[root@localhost ~]# ll
total 16
-rw-r--r-- 1 root root 1013 Mar 5 15:17 server.csr
-rw-r--r-- 1 root root 1751 Mar 5 15:13 server.key
[root@localhost ~]# cp server.key server.key.org
[root@localhost ~]# openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key
4、生成自签名证书
[root@localhost ~]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=CN/ST=GuangDong/L=ShenZhen/O=OPS/OU=OPS/CN=www.test.com
Getting Private key
5、apache、nginx设置SSL证书
apache设置SSL证书,并且实现http强制跳转到https
[root@localhost ~]# vi /etc/http/http.conf
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule rewrite_module modules/mod_rewrite.so
ServerName www.test.com:80
<Directory "/opt/abc/xyz">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
</Directory>
Include /etc/httpd/extra/httpd-ssl.conf [root@localhost ~]# vi /etc/httpd/extra/httpd-ssl.conf
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "/opt/abc/xyz"
ServerName www.test.com:443
ServerAdmin you@example.com
ErrorLog "/usr/local/apache2.4.25/logs/error_log"
TransferLog "/usr/local/apache2.4.25/logs/access_log"
SSLEngine on
SSLCertificateFile "/usr/local/apache/ssl/server.crt"
SSLCertificateKeyFile "/usr/local/apache/ssl/server.key"
nginx设置SSL证书(也可以设置成http强制跳转到https)
[root@localhost ~]# vi /usr/local/nginx/conf/nginx.conf
server {
listen 443;
server_name www.test.com;
ssl on;
ssl_certificate server.crt;
ssl_certificate_key server.key;
[root@localhost ~]# cp server.crt server.key /usr/local/nginx/conf/
[root@localhost ~]# cd /usr/local/nginx/conf/
[root@localhost conf]# ll
总用量 76
-rw-r--r--. 1 root root 1077 4月 5 11:26 fastcgi.conf
-rw-r--r--. 1 root root 1077 4月 5 11:26 fastcgi.conf.default
-rw-r--r--. 1 root root 1007 4月 5 11:26 fastcgi_params
-rw-r--r--. 1 root root 1007 4月 5 11:26 fastcgi_params.default
-rw-r--r--. 1 root root 2837 4月 5 11:26 koi-utf
-rw-r--r--. 1 root root 2223 4月 5 11:26 koi-win
-rw-r--r--. 1 root root 5170 4月 5 11:26 mime.types
-rw-r--r--. 1 root root 5170 4月 5 11:26 mime.types.default
-rw-r--r--. 1 root root 2746 4月 5 15:09 nginx.conf
-rw-r--r--. 1 root root 2656 4月 5 11:26 nginx.conf.default
-rw-r--r--. 1 root root 636 4月 5 11:26 scgi_params
-rw-r--r--. 1 root root 636 4月 5 11:26 scgi_params.default
-rw-r--r--. 1 root root 1200 4月 5 15:10 server.crt
-rw-r--r--. 1 root root 1679 4月 5 15:10 server.key
-rw-r--r--. 1 root root 664 4月 5 11:26 uwsgi_params
-rw-r--r--. 1 root root 664 4月 5 11:26 uwsgi_params.default
-rw-r--r--. 1 root root 3610 4月 5 11:26 win-utf
[root@localhost conf]# systemctl restart nginx
6、访问测试
https://192.168.146.129
转载于:https://blog.51cto.com/net881004/2374645
apache、nginx配置openssl自签名证书的更多相关文章
- Nginx 配置 HTTPS自签名证书
工具: OpenSSL ssl的开源实现,几乎实现了市面上所有的加密 libcrypto: 通用加密库, 任何软件要实现加密功能 链接调用这个库 libssl: TLS/SSL 加密库 openssl ...
- Nginx配置SSL自签名证书
生成自签名SSL证书 生成RSA密钥(过程需要设置一个密码,记住这个密码) $ openssl genrsa -des3 -out domain.key 1024 拷贝一个不需要输入密码的密钥文件 $ ...
- SSL证书部署HTTPS站点Apache/Nginx配置
SSL证书及HTTPS协议 SSL 证书是一种数字证书,它使用 Secure Socket Layer 协议在浏览器和 Web 服务器之间建立一条安全通道,从而实现:1.数据信息在客户端和服务器之间的 ...
- 用tomcat配置https自签名证书,解决 ios7.1以上系统, 苹果inHouse发布
用tomcat配置https自签名证书,解决 ios7.1以上系统苹果inHouse发布不能下载安装的问题教程,话说,我其实最讨厌配置某某环境了,因为某一个小环节一旦出错,你的所有工作往往会功亏一篑, ...
- 给Nginx配置一个自签名的SSL证书
转自廖雪峰的官方网站http://www.liaoxuefeng.com/ 要保证Web浏览器到服务器的安全连接,HTTPS几乎是唯一选择.HTTPS其实就是HTTP over SSL,也就是让HTT ...
- Nginx配置一个自签名的SSL证书
http://www.liaoxuefeng.com/article/0014189023237367e8d42829de24b6eaf893ca47df4fb5e000 要保证Web浏览器到服务器的 ...
- nginx配置openssl证书
引用出处: https://blog.csdn.net/liuchunming033/article/details/48470575 证书生成基本步骤: 生成私钥(.key)-->生成证书请求 ...
- Linux下生成openssl自签名证书
校验证书是否被 CA 证书签名,正确的情况: $ openssl verify -CAfile /etc/kubernetes/cert/ca.pem /etc/kubernetes/cert/kub ...
- springboot配置SSL自签名证书
1.证书生成 每一个JDK或者JRE里都有一个工具,叫做:keytool,安装了jdk或jre之后,配置好JAVA环境之后,就可以直接在控制台使用该命令生成自签名证书: 在控制台输入: keytool ...
随机推荐
- 【Redis】集群NetCore实战
环境准备 1. Redis集群(Windows集群搭建) 启动Redis集群,给每个节点加上Title start .conf start .conf start .conf start .conf ...
- 多线程之旅(Task 任务)
一.Task(任务)和ThreadPool(线程池)不同 源码 1.线程(Thread)是创建并发工具的底层类,但是在前几篇文章中我们介绍了Thread的特点,和实例.可以很明显发现局限性 ...
- New!一只菜鸟的学习之路....
今天拥有了自己的博客,希望在这里记录下自己成长的点点滴滴! 本博客主要记录: 1.在学习过程中遇到的问题及后续的解决办法: 2.技术上的困难,希望路过的大佬指点一二: 3.分享一些实用的技术材料: 4 ...
- javascript入门 之 ztree (九 单/复选框问题)
<!DOCTYPE html> <HTML> <HEAD> <meta http-equiv="content-type" content ...
- JAVA中使用Date和SimpleDateFromat类表示时间
转自:https://www.imooc.com/code/2335 仅做个人学习保存之用,侵删! 在程序开发中,经常需要处理日期和时间的相关数据,此时我们可以使用 java.util 包中的 Dat ...
- Django 表单处理流程
Django 的表单处理:视图获取请求,执行所需的任何操作,包括从模型中读取数据,然后生成并返回HTML页面(从模板中),我们传递一个包含要显示的数据的上下文.使事情变得更复杂的是,服务器还需要能够处 ...
- leetcode c++做题思路和题解(5)——堆的例题和总结
堆和优先队列 堆的简介, 是一种二叉树, 有最大堆和最小堆miniheap. 通常用于构建优先队列. 0. 目录 数据流中的第K大元素 1. 数据流中的第K大元素 数据流中的第K大元素 复杂度为log ...
- unity3d的键盘和鼠标输入
一.键盘的输入 •GetKey,GetKeyDown,GetKeyUp三个方法分别获取用户键盘按键的输入 1. GetKey:用户长按按键有效: bool down = Input.GetKeyDow ...
- Application.Exit
Application.Exit:通知winform消息循环退出.Environment.Exit:终止当前进程,返回exitcode给操作系统 Application.Exit会在所有前台线程退出后 ...
- Python导出数据到Excel表格-NotImplementedError: formatting_info=True not yet implemented
在使用Python写入数据到Excel表格中时出现报错信息记录:“NotImplementedError: formatting_info=True not yet implemented” 报错分析 ...