跳转到内容
搜索文档

Azure Dedicated HSM

最后更新 查看 MarkdownAgent 设置

本教程使用 Azure Dedicated HSM——一种基于 Gemalto SafeNet Luna a790 的经 FIPS 140-2 Level 3 认证的实现。


开始之前

请确保您已:


1. 创建、分配并初始化新分区

第一步是创建 HSM 分区,可以将其视为 Azure Dedicated HSM 设备中的独立逻辑 HSM。

vm$ ssh tenantadmin@hsm

[local_host] lunash:>hsm login
  Please enter the HSM Administrators' password:
  > ********


'hsm login' successful.


Command Result : 0 (Success)

[local_host] lunash:>partition create -partition KeylessSSL


          Type 'proceed' to create the partition, or
          'quit' to quit now.
          > proceed
'partition create' successful.


Command Result : 0 (Success)

接下来,需要将分区分配给客户端,在本例中是您的密钥服务器。

[local_host] lunash:>client assignpartition -client azure-keyless -partition KeylessSSL


'client assignPartition' successful.


Command Result : 0 (Success)

分配分区后,从虚拟服务器运行 lunacm 并初始化分区。

vm$ lunacm
lunacm (64-bit) v7.2.0-220. Copyright (c) 2018 SafeNet. All rights reserved.


  Available HSMs:

  Slot Id ->              0
  Label ->
  Serial Number ->        XXXXXXXXXXXXX
  Model ->                LunaSA 7.2.0
  Firmware Version ->     7.0.3
  Configuration ->        Luna User Partition With SO (PW) Signing With Cloning Mode
  Slot Description ->     Net Token Slot


  Current Slot Id: 0

lunacm:>partition init -label KeylessSSL -domain cloudflare

  Enter password for Partition SO: ********

  Re-enter password for Partition SO: ********

  You are about to initialize the partition.
  All contents of the partition will be destroyed.

  Are you sure you wish to continue?

  Type 'proceed' to continue, or 'quit' to quit now ->proceed

Command Result : No Error

2. 生成 RSA 密钥对和证书签名请求 (CSR)

在运行以下命令之前,请与您的信息安全和/或密码学团队确认组织批准的密钥创建程序。

# cmu generatekeypair -keyType=RSA -modulusBits=2048 -publicExponent=65537 -sign=1 -verify=1 -labelpublic=myrsakey -labelprivate=myrsakey -keygenmech=1

Please enter password for token in slot 0 : ********

# cmu list

Please enter password for token in slot 0 : ********
handle=51 label=myrsakey
handle=48 label=myrsakey

使用上一步中创建的密钥,生成可发送给公开受信任的证书颁发机构 (CA) 进行签名的 CSR。

# cmu requestCertificate -c="US" -o="Example, Inc." -cn="azure-dedicatedhsm.example.com" -s="California" -l="San Francisco" -publichandle=48 -privatehandle=51 -outputfile="rsa.csr" -sha256withrsa

Please enter password for token in slot 0 : ********
Using "CKM_SHA256_RSA_PKCS" Mechanism

3. 从证书颁发机构 (CA) 获取并上传已签名的证书

将上一步中创建的 CSR 提供给组织首选的 CA,按要求证明对域名的控制权,然后下载已签名的 SSL 证书。请遵循上传 Keyless SSL 证书中提供的说明。


4. 修改 gokeyless 配置文件并重启服务

最后,我们需要修改密钥服务器在启动时将读取的配置文件。请务必将 object=mykeypin-value=username:password 值更改为与您提供的密钥标签和创建的 CU 用户匹配。

打开 /etc/keyless/gokeyless.yaml,在紧接其后的位置:

private_key_stores:
  - dir: /etc/keyless/keys

添加:

- uri: pkcs11:token=KeylessSSL;object=myrsakey?module-path=/usr/safenet/lunaclient/lib/libCryptoki2_64.so&pin-value=password&max-sessions=1

保存配置文件后,重启 gokeyless 并验证其是否成功启动。

sudo systemctl restart gokeyless.service
sudo systemctl status gokeyless.service -l

这篇文档对您有帮助吗?