海运的博客

openssl验证ocsp及haproxy配置ocsp

发布时间:January 8, 2020 // 分类: // No Comments

获取网站公钥:

openssl s_client -connect www.haiyun.me:443 2>&1 < /dev/null | sed -n '/-----BEGIN/,/-----END/p' > www.haiyun.me.cer

获取签发者公钥,第一个为网站公钥,和上面获取的一样,等同于acme申请的免费ssl证书www.haiyun.me.cer,第二个为签发者公钥,两者合并等同于acme生成的fullchain.cer文件。

openssl s_client -connect www.haiyun.me:443 -showcerts 2>&1 < /dev/null | awk '/BEGIN/,/END/{ if(/BEGIN/){num++}; out="haiyun.me."num".cer"; print > out}'
#openssl s_client -showcerts -connect www.wikipedia.org:443 < /dev/null 2>&1 |  sed -n '/-----BEGIN/,/-----END/p' | sed -n '/^-----END CERTIFICATE-----/,$ p' | sed 1d > chain.pem

查看网站证书验证ocsp的网址:

openssl x509 -noout -ocsp_uri -in haiyun.me.1.cer 

ocsp验证:

openssl ocsp -noverify -no_nonce -issuer haiyun.me.2.cer -cert haiyun.me.1.cer -url http://ocsp.int-x3.letsencrypt.org --text

生成haproxy可用的ocsp文件:

openssl ocsp -noverify -no_nonce -issuer haiyun.me.2.cer -cert haiyun.me.1.cer -url http://ocsp.int-x3.letsencrypt.org -respout haproxy.ocsp

通过haproxy管理sock更新ocsp:

echo "set ssl ocsp-response `base64 -w 0 haproxy.ocsp`"|socat stdio /var/run/haproxy.sock  

如果提示以下错误:

OCSP single response: Certificate ID does not match any certificate or issuer.

因为haproxy有配置多个域名ssl证书,需先让haproxy加载ocsp文件再使用sock更新,将ocsp文件保存到haproxy配置的证书目录,名字更改为证书名ocsp,重新启动haproxy则自动加载ocsp文件。
如haproxy使用acme申请的Let’s Encrypt ecc免费证书:

cat fullchain.cer www.haiyun.me.key > www.haiyun.me.pem
mv haproxy.ocsp www.haiyun.me.pem.ocsp

haproxy配置:

bind :443 allow-0rtt ssl crt www.haiyun.me_ecc/www.haiyun.pem alpn http/1.1,h2

使用openssl验证网站配置的ocsp是否生效:

openssl s_client -connect www.haiyun.me:443 -status -tlsextdebug < /dev/null 2>&1 | sed -n '/OCSP Response Data:/,/======/p'

https://github.com/pierky/haproxy-ocsp-stapling-updater
https://icicimov.github.io/blog/server/HAProxy-OCSP-stapling/
https://raymii.org/s/articles/OpenSSL_Manually_Verify_a_certificate_against_an_OCSP.html
https://imququ.com/post/why-can-not-turn-on-ocsp-stapling.html

标签:none

评论已关闭

分类
最新文章
最近回复
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...
  • jiangker: good, very helpful to me
  • fengfeng: N1 armbian 能有编译下内核吗。。我要开启can 不懂怎么操作