community.crypto.acme_inspect 模块 – 向 ACME 服务器发送直接请求
注意
此模块是 community.crypto 集合 (版本 2.22.3) 的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.crypto
。您需要其他要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定: community.crypto.acme_inspect
。
概要
允许使用 ACME 协议 向 ACME 服务器发送直接请求,ACME 协议受 Let's Encrypt 等 CA 支持。
此模块可用于调试证书请求尝试失败的情况,例如,当 community.crypto.acme_certificate 失败或遇到您希望调查的问题时。
此模块还可用于直接访问 Ansible ACME 模块尚不支持的 ACME 服务器功能。
要求
执行此模块的主机需要以下要求。
openssl 或 cryptography >= 1.5
ipaddress
参数
参数 |
注释 |
---|---|
ACME 账户 RSA 或椭圆曲线密钥的内容。 与 如果未使用 **警告:**内容将写入临时文件,模块完成后 Ansible 将删除该文件。由于这是一个重要的私钥——它可以用来更改帐户密钥,或者在不知道其私钥的情况下吊销您的证书——这可能不可接受。 如果使用 |
|
用于解码帐户密钥的密码。 **注意:** |
|
包含 ACME 账户 RSA 或椭圆曲线密钥的文件路径。 可以使用 community.crypto.openssl_privatekey 或 community.crypto.openssl_privatekey_pipe 模块创建私钥。如果所需的 (cryptography) 库不可用,也可以使用 与 如果未使用 |
|
如果指定,则假定帐户 URI 如给定值。如果帐户密钥与该帐户不匹配,或者不存在具有此 URI 的帐户,则模块将失败。 |
|
要使用的 ACME 目录。这是访问 ACME CA 服务器 API 的入口点 URL。 出于安全原因,默认设置为 Let's Encrypt 暂存服务器(对于 ACME v1 协议)。这将创建技术上正确的但不受信任的证书。 对于 Let's Encrypt,所有暂存端点都可以在此处找到:https://letsencrypt.openssl.ac.cn/docs/staging-environment/。对于 Buypass,所有端点都可以在此处找到:https://community.buypass.com/t/63d4ay/buypass-go-ssl-endpoints 对于**Let's Encrypt**,ACME v2 的生产目录 URL 为 https://acme-v02.api.letsencrypt.org/directory。 对于**Buypass**,ACME v2 和 v1 的生产目录 URL 为 https://api.buypass.com/acme/directory。 对于**ZeroSSL**,ACME v2 的生产目录 URL 为 https://acme.zerossl.com/v2/DV90。 对于**Sectigo**,ACME v2 的生产目录 URL 为 https://acme-qa.secure.trust-provider.com/v2/DV。 此模块的备注包含此模块已针对其进行测试的 ACME 服务列表。 |
|
端点的 ACME 版本。 对于传统的 Let’s Encrypt 和 Buypass ACME 终端,此值必须为 自 community.crypto 2.0.0 版本起, 选项
|
|
用于访问 ACME 服务器上指定 URL 的方法。
选项
|
|
Ansible 应等待 ACME API 响应的时间。 此超时适用于所有 HTTP(S) 请求 (HEAD、GET、POST)。 默认值: |
|
确定要使用的加密后端。 默认选项为 如果设置为 如果设置为 选项
|
|
要发送请求的 URL。 如果 |
|
是否验证对 ACME 目录的 TLS 证书调用。 警告:仅应出于测试目的将其设置为 选项
|
属性
属性 |
支持 |
描述 |
---|---|---|
操作组: community.crypto.acme,acme |
在 |
|
支持:不支持 |
可以在 |
|
支持:不支持 |
在差异模式下,将返回有关已更改内容(或可能需要在 |
备注
注意
对于正确验证的 ACME v2 请求(
new-account
请求除外),必须指定account_uri
选项。使用
ansible
工具,community.crypto.acme_inspect 可用于直接执行 ACME 请求,无需编写剧本。例如,以下命令从 Let’s Encrypt 检索 ID 为 1 的 ACME 帐户(假设/path/to/key
是正确的私有帐户密钥):ansible localhost -m acme_inspect -a "account_key_src=/path/to/key acme_directory=https://acme-v02.api.letsencrypt.org/directory acme_version=2 account_uri=https://acme-v02.api.letsencrypt.org/acme/acct/1 method=get url=https://acme-v02.api.letsencrypt.org/acme/acct/1"
尽管默认值的选择使得该模块可以与 Let’s Encrypt CA 一起使用,但原则上,该模块可以与任何提供 ACME 终端的 CA 一起使用,例如 Buypass Go SSL。
到目前为止,ACME 模块仅由开发人员针对 Let’s Encrypt(暂存和生产)、Buypass(暂存和生产)、ZeroSSL(生产)和 Pebble 测试服务器 进行过测试。我们收到了社区反馈,表明它们也适用于 Sectigo ACME Service for InCommon。如果您在其他 ACME 服务器上遇到问题,请创建问题 以帮助我们支持它。我们也欢迎您反馈未提及的 ACME 服务器是否可行。
如果可以使用足够新的
cryptography
库版本(有关详细信息,请参见“要求”),则将使用它而不是openssl
二进制文件。可以使用select_crypto_backend
选项显式禁用或启用此功能。请注意,使用openssl
二进制文件会更慢且安全性更低,因为私钥内容始终必须存储在磁盘上(请参见account_key_content
)。
另请参阅
另请参阅
- 自动证书管理环境 (ACME)
ACME 协议规范 (RFC 8555)。
- ACME TLS ALPN 质询扩展
tls-alpn-01
质询的规范 (RFC 8737)。
示例
- name: Get directory
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
method: directory-only
register: directory
- name: Create an account
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
url: "{{ directory.newAccount}}"
method: post
content: '{"termsOfServiceAgreed":true}'
register: account_creation
# account_creation.headers.location contains the account URI
# if creation was successful
- name: Get account information
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
account_uri: "{{ account_creation.headers.location }}"
url: "{{ account_creation.headers.location }}"
method: get
- name: Update account contacts
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
account_uri: "{{ account_creation.headers.location }}"
url: "{{ account_creation.headers.location }}"
method: post
content: '{{ account_info | to_json }}'
vars:
account_info:
# For valid values, see
# https://tools.ietf.org/html/rfc8555#section-7.3
contact:
- mailto:[email protected]
- name: Create certificate order
community.crypto.acme_certificate:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
account_uri: "{{ account_creation.headers.location }}"
csr: /etc/pki/cert/csr/sample.com.csr
fullchain_dest: /etc/httpd/ssl/sample.com-fullchain.crt
challenge: http-01
register: certificate_request
# Assume something went wrong. certificate_request.order_uri contains
# the order URI.
- name: Get order information
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
account_uri: "{{ account_creation.headers.location }}"
url: "{{ certificate_request.order_uri }}"
method: get
register: order
- name: Get first authz for order
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
account_uri: "{{ account_creation.headers.location }}"
url: "{{ order.output_json.authorizations[0] }}"
method: get
register: authz
- name: Get HTTP-01 challenge for authz
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
account_uri: "{{ account_creation.headers.location }}"
url: "{{ authz.output_json.challenges | selectattr('type', 'equalto', 'http-01') }}"
method: get
register: http01challenge
- name: Activate HTTP-01 challenge manually
community.crypto.acme_inspect:
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
acme_version: 2
account_key_src: /etc/pki/cert/private/account.key
account_uri: "{{ account_creation.headers.location }}"
url: "{{ http01challenge.url }}"
method: post
content: '{}'
返回值
常用返回值已在此处记录,以下是此模块特有的字段
键 |
描述 |
---|---|
ACME 目录的内容 返回:始终返回 示例: |
|
请求的 HTTP 头 (使用小写键) 返回:始终返回 示例: |
|
输出结果被解析为 JSON 返回:如果输出可以被解析为 JSON 示例: |
|
原始文本输出 返回:始终返回 示例: |