通过OpenSSL获取私钥文件与证书文件
DevKit AI默认以HTTPS方式提供服务,需配置私钥文件和证书文件,可通过OpenSSL自行生成。
操作步骤
- 使用
SSH 远程登录工具,登录DevKit AI安装节点。 - 生成私钥文件。以生成加密私钥为例,若需生成不加密私钥,则无需指定-aes256参数。
1openssl genrsa -aes256 -out key.pem 2048
请根据提示输入私钥文件密码。
Enter PEM pass phrase: Verifying - Enter PEM pass phrase:
- 生成证书文件。
1openssl req -new -x509 -key key.pem -out cert.pem -days 3650
请根据提示输入私钥文件密码,Common Name填写服务访问的IP地址或域名,其余可填“.”跳过。
Enter pass phrase for key.pem:私钥文件密码 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]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []:服务访问的IP地址或域名 Email Address []:
- 进入DevKit AI安装目录,加密私钥密码。若生成不加密的私钥,则可跳过该步骤。
./encrypt
请根据提示输入需要加密的私钥密码。
请输入需要加密的内容: 加密后的密文: ******************************************************
- 将上述文件路径分别配置到config.yaml。
1 2 3 4 5 6
server: ssl: ssl_keyfile: /path/key.pem ssl_certfile: /path/cert.pem # 仅当ssl_keyfile指向加密私钥文件时填写(可选),需填入经encrypt加密后的值 ssl_keyfile_password: ******************************************************
- 将自签名证书导入Client端CA Bundle。
- 获取证书文件cert.pem到本地。
- 右键单击Windows“命令提示符”工具,选择以管理员身份运行,并执行以下命令导入证书。
C:\Users\username>certutil -user -addstore Root D:\\cert\cert.pem
“D:\\cert\cert.pem”为证书本地存放路径,请根据实际路径进行替换。
弹出安全警告提示,如下图所示。

单击“是(Y)”,返回如下信息则表示导入成功。
Root "受信任的根证书颁发机构" 签名与公钥匹配 证书 "xx.xx.xx.xx" 添加到存储。 CertUtil: -addstore 命令成功完成。
父主题: 常用操作