本地签发ssl证书(https)

说明

ssl证书主要用于https网络访问的安全认证

工具

下载本地自签证书程序https://github.com/FiloSottile/mkcert/releases
命令行mkcert-v1.4.4-windows-amd64 -?可以查看使用方法

生成步骤

1、mkcert-v1.4.4-windows-amd64 -install 安装本地根证书
2、生成自签证书:mkcert-v1.4.4-windows-amd64 localhost 127.0.0.1 根据提示有多种用法,多个IP或域名可空格隔开使用,生成的证书文件用于nginx中配置,两个文件格式:***.pem

使用步骤(他人使用才需要)

1、mkcert-v1.4.4-windows-amd64 -CAROOT 查看根证书位置
2、将根证书目录下的rootCA.pem改名为***.cer进行访问者发放
3、访问者首先安装证书,安装证书目录需要选择证书存储然后受信任的根证书颁发凭证,再确认。

效果

网络服务配置好证书后可通过https访问签名指向的地址
image

附 nginx 的配置方式

该配置下可同时使用http与https访问相同的指向地址

server {
listen 80;
listen 443 ssl;
server_name localhost;

charset koi8-r;

access_log logs/host.access.log main;

ssl_certificate E:/nginx/nginx-1.21.3/ssl/192.168.2.153+1.pem;
ssl_certificate_key E:/nginx/nginx-1.21.3/ssl/192.168.2.153+1-key.pem;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
root html;
index index.html index.htm;
}

location /develop/ {
root ../../workspace/;
index index.html index.htm;
autoindex on;
}

location /WebResource/ {
root ../../workspace/develop;
index index.html index.htm;
# 当请求的流量超500KB后进行限速
limit_rate_after 500k;
# 限速 1024KB/s
limit_rate 1024k;
autoindex on;
}
}

原文链接:https://blog.csdn.net/mfkarj/article/details/127632656

posted @ 2024-10-22 11:25  请明月  阅读(371)  评论(0)    收藏  举报