CreateSelfSignedCertificateEx
安全和签名
描述
创建可选密钥算法的自签名证书,连同私钥一并导出到带密码保护的 PFX 文件
KeyKind 0 保持 CreateSelfSignedCertificate 的既有 RSA 路径;KeyKind 1 通过 CNG Microsoft Software Key Storage Provider 创建 ECDSA 密钥,将 KeyBits 256/384/521 映射到 P-256/P-384/P-521 曲线并以 ecdsa-with-SHA256 为证书签名
ECDSA 密钥存放在导出后即删除的一次性 CNG 容器中;只有 PFX 文件保留密钥材料
语法
Delphi
Function TPDFlib.CreateSelfSignedCertificateEx(Const SubjectName, PFXFileName, PFXPassword: WideString; ValidDays, KeyBits, KeyKind: Integer): Integer;ActiveX
Function PDFlib::CreateSelfSignedCertificateEx(SubjectName As String, PFXFileName As String, PFXPassword As String, ValidDays As Long, KeyBits As Long, KeyKind As Long) As LongDLL
int DLCreateSelfSignedCertificateEx(int InstanceID, const wchar_t* SubjectName, const wchar_t* PFXFileName, const wchar_t* PFXPassword, int ValidDays, int KeyBits, int KeyKind);
int DLCreateSelfSignedCertificateExA(int InstanceID, const char* SubjectName, const char* PFXFileName, const char* PFXPassword, int ValidDays, int KeyBits, int KeyKind);参数
| SubjectName | 主题;不含 = 字符时自动加 CN= 前缀 |
|---|---|
| PFXFileName | 要写出的 PFX 文件 |
| PFXPassword | PFX 密码 |
| ValidDays | 有效天数,最小 1;低于 1 的值按 365 处理 |
| KeyBits | KeyKind 0 的 RSA 位长;KeyKind 1 的曲线选择 256/384/521,其他值选 P-256 |
| KeyKind | 0 = RSA,1 = ECDSA |
返回值
| 1 | 证书与 PFX 已写出 |
|---|---|
| 0 | 生成或导出失败;非 Windows 平台不支持 ECDSA 生成 |