自签证书让Chrome信任的方式

自签证书让Chrome信任的方式(域名情况)

网站是搭建在linux上的,内容大概是一个code-server;我要在windows的chrome中访问,在Linux机器上自签了一个证书,准备让windows中的chrome信任。linux装好openssl。首先买好域名,配置好解析,然后在linux上:

shell 复制代码
mkdir -p [选一个放证书的目录]
cd [选一个放证书的目录]
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myssl.key -out myssl.crt

在放证书的路径下写一个openssl.cnf如下

text 复制代码
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no

[req_distinguished_name]
C = CN
ST = BeiJing(随便写个省份)
L = BeiJing (随便写个城市)
O = BlahBlah (随便写个公司)
OU = BlahBlah (随便写个区域)
CN = website.mydomain.cn (这部分得和域名一样,切记)

[v3_req]
keyUsage = digitalSignature, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names

[alt_names]
DNS.1 = website.mydomain.cn (这部分得和域名一样,切记)

执行

shell 复制代码
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myssl.key -out myssl.crt -config openssl.cnf

然后配置nginx,这里主要看证书部分,就是server往下的5~6行,其他我也懒得删了

复制代码
#user  nobody;
worker_processes  1;
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
    listen 443 ssl;
    server_name website.mydomain.cn;

    ssl_certificate [放证书的路径]/myssl.crt;
    ssl_certificate_key [放证书的路径]/myssl.key;

            location / {
                proxy_pass https://localhost:8080;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
            }
    }
}

重启nginx

然后把myssl.crt下载下来,打开chrome://settings,也就是设置,搜索证书,在安全 那一项里,有一个管理设备证书,然后点进去以后选导入,然后选这个证书导入进来,选择将所有证书放入下列存储的时候有个浏览,受信任的发布者和受信任的根证书颁发机构我都导入了一遍,然后不安全就消失了,websocket也能用了。

相关推荐
chlk1231 小时前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑1 小时前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件2 小时前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号12 小时前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash16 小时前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI1 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行2 天前
Linux和window共享文件夹
linux
木心月转码ing2 天前
WSL+Cpp开发环境配置
linux
简离3 天前
前端调试实战:基于 chrome://webrtc-internals/ 高效排查WebRTC问题
前端·chrome·webrtc
崔小汤呀3 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端