How to set up OCSP server

本文介绍如何使用OpenSSL搭建OCSP服务器,并创建包含OCSP指针的定制证书进行撤销检查。文章详细介绍了安装配置OpenSSL、准备证书、启动OCSP服务器及验证流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Overview:

    I started learning OCSP as a job demand. In our work, we often need to create some custom certificates(e.g. certificates that only contain a pointer to an OCSP responder or certificates that only contain a pointer to CRL information). This type of test can really only be done using an internal test environment (we cannot depend on public CAs like VeriSign) where we are able to have full control over what we put in the certificate.

Tool:

    We set up OCSP server using OpenSSL since it's an Open Source project and is an easy way to set up OCSP.

Detail Steps:

1. Install OpenSSL:

  • Download latest openssl build from www.openssl.org to a Linux or Solaris machine(windows is not acceptable). For example,openssl-1.1.0e.tar.gz
  • tar -zxvf openssl-1.0.1e.tar.gz 
  • cd openssl-1.0.1e dir 
  • ./config --openssldir={openssl_install_dir}  
  • make  
  • make test  
  • make install

2. Prepare your certificates

Create root ca

  • mkdir  {your_dir}/ocsp and cd {your_dir}/ocsp
  • mkdir certs private crl newcerts under {your_dir}/ocsp
  • Create a serial file and an index.txt file:

              echo 1000 > serial          

              touch index.txt  

             "serial" file is used to name the new certificates generated; "index.txt" is the index file that OpenSSL creates when the CA is set up, and updates every time the CA signs or revokes a certificate.  

  • Prepare openssl.cnf
  • Create a root certificate

              {openssl_install_dir}/bin/openssl req -config ./openssl.cnf -new -x509  -keyout ./private/rootkey.pem -out ./certs/rootcacert.pem -days 3650

Create custom certificates

        For example, you want a certificate that contains a pointer to an OCSP responder to do cert revocation checking.  And the OCSP server will be running on www.ocspserver.com on port 8080.

  • First, you need to configure openssl.cnf file under {your_dir}/ocsp: add the new line to the usr_cert stanza

             [ usr_cert ]

             authorityInfoAccess = OCSP;URI:http://www.ocspserver.com:8080

            This line will add a new attribute to issued certs that tells clients where the CA’s OCSP server is located so it can check the validity of the cert.

  • Request a certificate
             {openssl_install_dir}/bin/openssl req -config ./openssl.cnf -new -nodes  -keyout  private/good_cert.key -out good_cert.csr -days 3650
  • Use root CA to sign this certificate
             {openssl_install_dir}/bin/openssl ca -config ./openssl.cnf -policy   policy_anything -out certs/good_cert.pem -infiles good_cert.csr

3. Start up OCSP Server

     Start OCSP server on port 8080      
     {openssl_install_dir}/bin/openssl ocsp -index index.txt -port 8080 -rkey private/rootkey.pem -rsigner certs/rootcacert.pem -CA certs/rootcacert.pem -text -out log1.txt -ignore_err

4. Check if our OCSP server is functioning correctly

    {openssl_install_dir}/bin/openssl ocsp -CAfile rootcacert.pem -issuer rootcacert.pem -cert good_cert.pem -url http://www.ocspserver.com:8080 -resp_text

    If you see the following message, this means OCSP server works:
OCSP Response Data:
OCSP Response Status: successful (0x0)
Response Type: Basic OCSP Response

Certificate ID:
Hash Algorithm: sha1
Serial Number: 06
...
Response verify OK
good_cert.pem: good










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值