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

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
阮一峰的网络日志
阮一峰的网络日志
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
T
Tailwind CSS Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
Webroot Blog
Webroot Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
The Cloudflare Blog
T
Threat Research - Cisco Blogs
V
Visual Studio Blog
Jina AI
Jina AI
V
V2EX
I
InfoQ
Latest news
Latest news
P
Proofpoint News Feed
T
Threatpost
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
美团技术团队
The Register - Security
The Register - Security
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
Cloudbric
Cloudbric
Microsoft Azure Blog
Microsoft Azure Blog
C
Cisco Blogs
U
Unit 42
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
V
Vulnerabilities – Threatpost
TaoSecurity Blog
TaoSecurity Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recent Commits to openclaw:main
Recent Commits to openclaw:main
W
WeLiveSecurity
博客园 - 司徒正美
T
The Exploit Database - CXSecurity.com
小众软件
小众软件
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
N
News and Events Feed by Topic

杂烩饭

使用 RustFS 自建对象存储 使用cURL命令管理对象存储(s3) AGENTS.md Prometheus使用kubeconfig做k8s的service 自动发现监控 定制Windows系统镜像iso 使用create-dmg工具制作dmg安装包 使用create-dmg工具制作dmg安装包 - 技术栈 superpowers Nexus仓库搭建记录 Git Merge代码冲突的解决方式 在 Linux 系统中安装与配置 OpenVPN:从入门到精通 使用 Easytier-web 管理 easytier 节点 ingress-nginx 去除指定context path 在macOS上使用MusicPlayer2听本地音乐 Kubernetes 1.34 + RHEL10 + Cilium + kube-vip 高可用集群部署 使用腾讯云CLS收集TKE(k8s)业务日志 容器调试工具之BusyBox 无Docker环境进行容器镜像操作 使用kubeadm部署一套高可用k8s集群1.34 for Ubuntu 正在运行的Docker容器增加端口映射 轻量级组网工具WireGuard 在Kubernetes中部署一个单节点Elasticsearch 使用openssl制作自签名双向认证(mTLS)证书 minio自建对象存储 ingress-nginx 使用自定义的nginx配置 P12格式证书与PEM格式转换 使用blackbox-exporter做域名监控 记一次MySQL字符集转换导致的故障 Prometheus自动监控K8S集群中的service Grafana 查询SQL 自定义变量 使用selenium来实现Grafana的自动截图
使用双向认证增加git仓库安全性
张理坤 · 2025-06-04 · via 杂烩饭

双向认证是用户需要提供证书来访问服务器,没有证书的用户不允许访问服务器,并且在服务端可以实现吊销指定用户的证书来实现禁止用户访问。配置 https 双向认证会影响到使用 https 协议拉取和推送代码,以及 git lfs 的正常使用 (lfs 使用 https 协议),ssh 协议使用代码仓库不受影响。

配置双向认证

我是用的自签名证书,自签名证书的文档可以查看 制作和使用自签名证书 或者我的开源项目:https://github.com/iuxt/my_cert.git

服务器上的 nginx 上配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
listen 443 ssl;
server_name example.com;

ssl_certificate /path/to/your/server.crt;
ssl_certificate_key /path/to/your/server.key;

ssl_client_certificate /path/to/your/ca.crt; # 配置 CA 证书,用于验证客户端证书的签发者
ssl_verify_client on; # 启用客户端证书验证
ssl_crl /path/to/your/crl.pem; # 配置 CRL 文件路径,用于检查吊销的证书

location / {
root /var/www/html;
index index.html;
}
}

配置好之后,打开网页会提示:
image.png

操作系统信任 CA 证书

Windows

Windows 将证书导入到系统的个人分类下。

macOS

macOS– 待补充。

Linux

Debian 系 Linux:

1
2
sudo cp cacert.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates

RedHat 系 Linux:

1
2
sudo cp cacert.crt /etc/pki/ca-trust/source/anchors/
sudo update-ca-trust

信任完成后,浏览器重启后再次打开 git 网页:
选择证书,点击确定,就可以正常打开页面了。
image.png

上面的配置,浏览器已经可以正常携带证书来访问指定的服务了,但是 git 客户端还不行,需要对 git 仓库进行配置。

1
2
3

git config http.sslCert C:\Users\iuxt\OneDrive\keys\manage.crt
git config http.sslkey C:\Users\iuxt\OneDrive\keys\manage.key

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 杂烩饭