AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 649990
Accepted
dotancohen
dotancohen
Asked: 2014-12-09 07:03:53 +0800 CST2014-12-09 07:03:53 +0800 CST 2014-12-09 07:03:53 +0800 CST

SSL 证书请求的非交互式创建

  • 772

有没有办法通过在初始命令上指定所有必需的参数来创建 SSL 证书请求?我正在编写一个基于 CLI 的 Web 服务器控制面板,如果可能,我想在执行时避免使用期望openssl。

这是创建证书请求的典型方式:

$ openssl req -new -newkey rsa:2048 -nodes -sha256 -keyout foobar.com.key -out foobar.com.csr
Generating a 2048 bit RSA private key
.................................................+++
........................................+++
writing new private key to 'foobar.com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New Sweden
Locality Name (eg, city) []:Stockholm
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Scandanavian Ventures, Inc.
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:foobar.com
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:FooBar

我希望看到这样的东西:( 不起作用的例子)

$ openssl req -new -newkey rsa:2048 -nodes -sha256 -keyout foobar.com.key -out foobar.com.csr \
-Country US \
-State "New Sweden" \
-Locality Stockholm \
-Organization "Scandanavian Ventures, Inc." \
-CommonName  foobar.com \
-EmailAddress [email protected] \
-Company FooBar

精美的手册页对此事无话可说,我也无法通过 Google 找到任何内容。SSL 证书请求生成必须是一个交互式过程,还是有某种方法可以在单个命令中指定所有参数?

这是在 Debian 派生的 Linux 发行版上运行openssl 1.0.1.

linux
  • 3 3 个回答
  • 16767 Views

3 个回答

  • Voted
  1. Best Answer
    Archemar
    2014-12-09T07:47:40+08:002014-12-09T07:47:40+08:00

    您缺少两部分:

    主题行,可以称为

    -subj "/C=US/ST=New Sweden/L=Stockholm /O=.../OU=.../CN=.../emailAddress=..."
    
    • 将 ... 替换为值,即X=X509 代码(组织/组织单位/等...)

    密码值,可以称为

    -passout pass:client11
    -passin  pass:client11
    
    • 给出输出/输入密码

    我对新钥匙的呼唤看起来像

    openssl genrsa -aes256 -out lib/client1.key -passout pass:client11 1024
    openssl rsa -in lib/client1.key -passin pass:client11 -out lib/client1-nokey.key
    
    openssl req -new -key lib/client1.key -subj req -new \
        -passin pass:client11 -out lib/client1.csr \
        -subj "/C=US/ST=New Sweden/L=Stockholm/O=.../OU=.../CN=.../emailAddress=..."
    

    (现在我看到了,有两个-new……)

    • 27
  2. JorgeM
    2018-11-13T13:34:19+08:002018-11-13T13:34:19+08:00

    我附加到我的常规 openssl 命令:

    openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/key.pem -out /etc/ssl/private/cert.pem

    这一行:

    -subj "/C=PE/ST=Lima/L=Lima/O=Acme Inc. /OU=IT Department/CN=acme.com"
    

    描述:

    • 国家名称(2 个字母代码)[AU]:PE
    • 州或省名称(全名)[Some-State]:利马
    • 地区名称(例如,城市)[]:Lima
    • 组织名称(例如公司)[Internet Widgits Pty Ltd]:Acme Inc.
    • 组织单位名称(例如,部分)[]:IT 部门
    • 通用名称(例如服务器 FQDN 或您的姓名)[]:acme.com

    像分隔符一样使用“/”。

    • 7
  3. eject
    2014-12-09T07:23:17+08:002014-12-09T07:23:17+08:00

    检查官方文档-batch中描述的选项。

    • 3

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve