惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
Hacker News: Ask HN
Hacker News: Ask HN
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Proofpoint News Feed
A
Arctic Wolf
Forbes - Security
Forbes - Security
Spread Privacy
Spread Privacy
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
Latest news
Latest news
AWS News Blog
AWS News Blog
M
MIT News - Artificial intelligence
GbyAI
GbyAI
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
Help Net Security
Help Net Security
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Schneier on Security
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
PCI Perspectives
PCI Perspectives
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
SecWiki News
SecWiki News
TaoSecurity Blog
TaoSecurity Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
G
Google Developers Blog
H
Hacker News: Front Page
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
博客园 - 叶小钗
T
Troy Hunt's Blog
F
Full Disclosure
T
Threat Research - Cisco Blogs

博客园 - ayanmw

极度推荐: 9router 一个npm服务,可以让你将白嫖到的所有AI token以及付费API都集中到一起 开源项目介绍 OpenTeam 命令行 检测验证网站的 SSL证书 是否安全 关闭夸克浏览器在windows资源管理器中,图片右键菜单的万能转换开关 golang的defer 深坑 Windows Terminal 清屏方法 Ctrl+Shift+K 免费二级域名以及设置SSL证书和解析 docker加速镜像 golang + AI 写一个可以 一键让nas下载百度网盘链接的文件 的程序 raid 为什么而不可以两个硬盘交叉读写和交叉备份? google-protobuf库 在golang语言下的插件扩展 golang 空切片和nil切片 有区别吗? golang json库 忽略 omitempty Go语言: golang如何判断一个结构体的一个方法是匿名组合的,还是该结构体自己的方法? golang 获得一个结构体的字节大小 吐槽 WPS 流氓行为: WPS 未经用户允许, 就建立了 WPS本地云盘 , 然后 云文档的文件 莫名其妙的的被删除了, 现在只能开会员恢复WPS云空间回收站的文件. 预测未来会有 内嵌AI大模型的游戏 好奇: windows10+都可以运行多个linux子系统了,为什么不支持运行多个windows子系统呢? gorm使用事务并发情况下切有最大mysql连接数限制的情况下的BUG,踩坑了 2024年 个人养老金 账户 应知应会 两个Mysql唯一索引的交换: 避免重复索引 Duplicate entry '3' for key 'priority_UNIQUE'
Nginx 使用自签名 SSL 证书
ayanmw · 2026-02-04 · via 博客园 - ayanmw

方法一 使用 snakeoil

使用 apt 安装的 nginx,默认配置文件中会有一行被注释的 include snippets/snakeoil.conf; 解除注释,通过 systemctl reload nginx 重新加载配置即可。

若重新加载失败提示

nginx: [emerg] cannot load certificate "/etc/ssl/certs/ssl-cert-snakeoil.pem": BIO_new_file() failed (SSL: 
error:02001002:system library:fopen:No such file or directory:fopen('/etc/ssl/certs/ssl-cert-snakeoil.pem','r') 
error:2006D080:BIO routines:BIO_new_file:no such file)

则需要使用 apt install ssl-cert 安装依赖,再次重新加载配置即可

方法二 使用 OpenSSL 自签名 (重点)

创建私钥

openssl genrsa -out server.key 2048

创建证书签名请求

openssl req -new -key server.key -out server.csr

此时可以根据自己需要对信息进行填写,需要注意 Common Name 必须为对应网站域名或ip地址

output and input:

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) [AU]:**cn**
State or Province Name (full name) [Some-State]:**localhost**
Locality Name (eg, city) []:**sh**
Organization Name (eg, company) [Internet Widgits Pty Ltd]:****
Organizational Unit Name (eg, section) []:****
Common Name (e.g. server FQDN or YOUR name) []:**localhost**
Email Address []:**admin@localhost**

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:**nopass**
An optional company name []:**cn-ltd**

创建自签名证书

openssl x509 -req -in server.csr -signkey server.key -out server.crt

output:

Certificate request self-signature ok
subject=C = cn, ST = localhost, L = sh, O = Internet Widgits Pty Ltd, CN = localhost, emailAddress = admin@localhost

配置 nginx

server {
      listen              443 ssl;
      ssl_certificate     /path/to/server.crt
      ssl_certificate_key /path/to/server.key
      ....
}

配置完成后使用 systemctl reload nginx 来重载配置

当使用 Chrome 访问自签名证书的网站时,会提示不安全。

解决方法 就是 忽略 或者 添加到本地信任机构证书(貌似没什么卵用)

意义:

起码 你有了SSL证书 用于开发、部署测试。

copy from:

https://jackyu.cn/tech/nginx-selfsign-ssl-cert/