搜索

2.8. 使用 GnuTLS 为 TLS 客户端证书创建私钥和 CSR

download PDF

要获取证书,您必须首先为您的客户端创建私钥和证书签名请求(CSR)。

流程

  1. 在客户端系统上生成私钥,例如:

    $ certtool --generate-privkey --sec-param High --outfile <example-client.key>
  2. 可选:使用您选择的文本编辑器来准备一个简化创建 CSR 的配置文件,例如:

    $ vim <example_client.cnf>
    signing_key
    encryption_key
    
    tls_www_client
    
    cn = "client.example.com"
    email = "client@example.com"
  3. 使用之前创建的私钥创建 CSR:

    $ certtool --generate-request --template <example-client.cfg> --load-privkey <example-client.key> --outfile <example-client.crq>

    如果省略 --template 选项, certtool 工具会提示您输入额外信息,例如:

    Generating a PKCS #10 certificate request...
    Country name (2 chars): <US>
    State or province name: <Washington>
    Locality name: <Seattle>
    Organization name: <Example Organization>
    Organizational unit name:
    Common name: <server.example.com>

后续步骤

验证

  1. 检查证书的人类可读部分是否与您的要求匹配,例如:

    $ certtool --certificate-info --infile <example-client.crt>
    Certificate:
    …
                X509v3 Extended Key Usage:
                    TLS Web Client Authentication
                X509v3 Subject Alternative Name:
                    email:client@example.com
    …

其他资源

  • certtool (1) 手册页
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.