CreateSelfSignedCertificateEx

Sécurité et signatures

Description

Crée un certificat auto-signé avec un algorithme de clé au choix et l’exporte — clé privée comprise — vers un fichier PFX protégé par mot de passe

KeyKind 0 conserve le chemin RSA historique de CreateSelfSignedCertificate ; KeyKind 1 crée une clé ECDSA via le fournisseur CNG Microsoft Software Key Storage Provider, en mappant KeyBits 256/384/521 sur les courbes P-256/P-384/P-521 et en signant le certificat avec ecdsa-with-SHA256

La clé ECDSA vit dans un conteneur CNG jetable supprimé après l’export ; seul le fichier PFX conserve le matériau de clé

Syntaxe

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 Long

DLL

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);

Paramètres

SubjectNameLe sujet, préfixé par CN= quand il ne contient aucun caractère =
PFXFileNameLe fichier PFX à écrire
PFXPasswordLe mot de passe du PFX
ValidDaysJours de validité, minimum 1 ; les valeurs sous 1 deviennent 365
KeyBitsTaille RSA en bits pour KeyKind 0 ; sélecteur de courbe 256/384/521 pour KeyKind 1, les autres valeurs sélectionnent P-256
KeyKind0 = RSA, 1 = ECDSA

Valeurs de retour

1Le certificat et le PFX ont été écrits
0La génération ou l’export a échoué ; sur les plateformes non Windows, la génération ECDSA n’est pas disponible

Voir aussi

CreateSelfSignedCertificate, SetSignProcessPFXFromFile