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 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);Paramètres
| SubjectName | Le sujet, préfixé par CN= quand il ne contient aucun caractère = |
|---|---|
| PFXFileName | Le fichier PFX à écrire |
| PFXPassword | Le mot de passe du PFX |
| ValidDays | Jours de validité, minimum 1 ; les valeurs sous 1 deviennent 365 |
| KeyBits | Taille RSA en bits pour KeyKind 0 ; sélecteur de courbe 256/384/521 pour KeyKind 1, les autres valeurs sélectionnent P-256 |
| KeyKind | 0 = RSA, 1 = ECDSA |
Valeurs de retour
| 1 | Le certificat et le PFX ont été écrits |
|---|---|
| 0 | La génération ou l’export a échoué ; sur les plateformes non Windows, la génération ECDSA n’est pas disponible |