community.crypto.openssl_signature_info 模块 – 使用 OpenSSL 验证签名
注意
此模块是 community.crypto 集合 (版本 2.22.3) 的一部分。
如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.crypto。您需要其他需求才能使用此模块,请参阅 需求 以了解详细信息。
要在 playbook 中使用它,请指定:community.crypto.openssl_signature_info。
community.crypto 1.1.0 中的新增功能
概要
- 此模块允许用户通过证书验证文件的签名。 
- 该模块使用 cryptography Python 库。 
需求
执行此模块的主机需要以下需求。
- cryptography >= 1.4 (某些密钥类型需要较新的版本) 
参数
| 参数 | 注释 | 
|---|---|
| 用于验证签名的证书内容。 必须指定  | |
| 用于验证签名的证书的路径。 必须指定  | |
| 要验证的已签名文件。 此文件将仅被读取,不会被修改。 | |
| 确定要使用的加密后端。 默认选择是  如果设置为  选项 
 | |
| Base64 编码的签名。 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全支持 此操作不会修改状态。 | 可以在  | |
| 支持: N/A 此操作不会修改状态。 | 处于 diff 模式时,将返回有关已更改内容(或可能需要在  | 
备注
注意
- 使用 - cryptography后端时,以下密钥类型至少需要以下- cryptography版本:RSA 密钥:- cryptography>= 1.4 DSA 和 ECDSA 密钥:- cryptography>= 1.5 ed448 和 ed25519 密钥:- cryptography>= 2.6
另请参阅
另请参阅
- community.crypto.openssl_signature
- 使用 OpenSSL 签名数据。 
- community.crypto.x509_certificate
- 生成和/或检查 OpenSSL 证书。 
示例
- name: Sign example file
  community.crypto.openssl_signature:
    privatekey_path: private.key
    path: /tmp/example_file
  register: sig
- name: Verify signature of example file
  community.crypto.openssl_signature_info:
    certificate_path: cert.pem
    path: /tmp/example_file
    signature: "{{ sig.signature }}"
  register: verify
- name: Make sure the signature is valid
  ansible.builtin.assert:
    that:
      - verify.valid
返回值
常见返回值已记录在 此处,以下是此模块独有的字段
| 键 | 描述 | 
|---|---|
| 
 返回:成功 | 
