CreateSelfSignedCertificateEx
Sicurezza e firme
Descrizione
Crea un certificato autofirmato con un algoritmo di chiave selezionabile e lo esporta — chiave privata inclusa — in un file PFX protetto da password
KeyKind 0 mantiene il percorso RSA storico di CreateSelfSignedCertificate; KeyKind 1 crea una chiave ECDSA tramite il provider CNG Microsoft Software Key Storage Provider, mappando KeyBits 256/384/521 sulle curve P-256/P-384/P-521 e firmando il certificato con ecdsa-with-SHA256
La chiave ECDSA vive in un contenitore CNG usa e getta eliminato dopo l'esportazione; solo il file PFX conserva il materiale della chiave
Sintassi
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);Parametri
| SubjectName | Il subject, preceduto da CN= quando non contiene alcun carattere = |
|---|---|
| PFXFileName | Il file PFX da scrivere |
| PFXPassword | La password del PFX |
| ValidDays | Giorni di validità, minimo 1; i valori sotto 1 diventano 365 |
| KeyBits | Lunghezza RSA in bit per KeyKind 0; selettore di curva 256/384/521 per KeyKind 1, gli altri valori selezionano P-256 |
| KeyKind | 0 = RSA, 1 = ECDSA |
Valori restituiti
| 1 | Il certificato e il PFX sono stati scritti |
|---|---|
| 0 | La generazione o l'esportazione è fallita; sulle piattaforme non Windows la generazione ECDSA non è disponibile |