Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Convert PFX with ECC Private Key and Cert to Encrypted PEMLoads a PFX (PKCS12) containing an ECC Certificate and it's ECC private key, and converts to encrypted PEM. Note: This example requires Chilkat v9.5.0.66 or greater.
#include <C_CkPfxW.h> void ChilkatSample(void) { HCkPfxW pfx; BOOL success; BOOL extendedAttrs; BOOL noKeys; BOOL noCerts; BOOL noCaCerts; const wchar_t *encryptAlg; const wchar_t *pemPassword; const wchar_t *strPem; // IMPORTANT: This example requires Chilkat v9.5.0.66 or greater. pfx = CkPfxW_Create(); success = CkPfxW_LoadPfxFile(pfx,L"qa_data/pfx/myEccCert.p12",L"MY_ECC_PFX_PASSWORD"); if (success != TRUE) { wprintf(L"%s\n",CkPfxW_lastErrorText(pfx)); CkPfxW_Dispose(pfx); return; } // If extendedAttrs is TRUE, then extended properties (Bag Attributes and Key Attributes) are included in the output. extendedAttrs = FALSE; // Set noKeys = TRUE to omit private keys from the output. noKeys = FALSE; // Set noCerts = TRUE to omit certificates from the output. noCerts = FALSE; // Set noCaCerts = TRUE to omit CA certificates from the output. noCaCerts = FALSE; // The encrypt algorithm can be "des3", "aes128", "aes192", or "aes256" encryptAlg = L"aes128"; pemPassword = L"secret123"; strPem = CkPfxW_toPemEx(pfx,extendedAttrs,noKeys,noCerts,noCaCerts,encryptAlg,pemPassword); wprintf(L"%s\n",strPem); // Sample output: // // -----BEGIN ENCRYPTED PRIVATE KEY----- // MIGtMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAiweNs9xIWNoAICCAAw // HQYJYIZIAWUDBAECBBCz0IMryNxuJEo5ChMktg9cBGCsKDEeRqGJX4g/X2c6CNtK // I8q7KClUwy9ms7ckHZAw/997WuW9QIGGnJEfHL/jSJsZViDwFAB4sunmdHSOTGMD // 3ZINNlkA+XobMaQtj1HNERtb1qskW1mf/X0sauw5aPA= // -----END ENCRYPTED PRIVATE KEY----- // -----BEGIN CERTIFICATE----- // MIICzjCCAlOgAwIBAgIETULS8zAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJVUzEW // MBQGA1UEChMNRW50cnVzdCwgSW5jLjEfMB0GA1UECxMWRm9yIFRlc3QgUHVycG9z // ZXMgT25seTElMCMGA1UEAxMcRW50cnVzdCBFQ0MgRGVtb25zdHJhdGlvbiBDQTAe // Fw0xNjAzMTgxMjM5MzFaFw0xNjA1MTcxMzA5MzFaMFgxHzAdBgNVBAsTFkZvciBU // ZXN0IFB1cnBvc2VzIE9ubHkxHTAbBgNVBAsTFFBlcnNvbmEgTm90IFZlcmlmaWVk // MRYwFAYDVQQDEw1DaGlsa2F0IEFkbWluMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE // uB62JGMJKXnp1PNsOOIYKGhrzfLev3O+UuthL6UzEqNNDTd8dEYMUQP/DTS3qk98 // gyQEFxdmZUsPF0fFokkZZ1cV6z7QD3MsPvSjrBzB0GUB3r8CLnDK/F4pF2Q995hr // o4HYMIHVMA4GA1UdDwEB/wQEAwIDiDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYB // BQUHAwQwNwYDVR0fBDAwLjAsoCqgKIYmaHR0cDovL2NybC5lbnRydXN0LmNvbS9D // UkwvZWNjZGVtby5jcmwwIAYDVR0RBBkwF4EVYWRtaW5AY2hpbGthdHNvZnQuY29t // MB8GA1UdIwQYMBaAFCQFS+Fkghr4Ccz7eHkh+nDmkzLqMB0GA1UdDgQWBBTB82fm // vrdG2iX5uS/agVW3L4DisjAJBgNVHRMEAjAAMAoGCCqGSM49BAMDA2kAMGYCMQCH // ILghMprWoYPEp9mCE+tpVE7vYwkFV3m0RDzT2BSUezL8Ky78XNk+XPqSB2biT70C // MQDCase1oaPY4AxCmjB+rEB1ir+QS8mrtF+iCSqHVv1aIxT6abQL57BZSdvwIm/T // T8o= // -----END CERTIFICATE----- // -----BEGIN CERTIFICATE----- // MIICljCCAhugAwIBAgIETUHhezAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJVUzEW // MBQGA1UEChMNRW50cnVzdCwgSW5jLjEfMB0GA1UECxMWRm9yIFRlc3QgUHVycG9z // ZXMgT25seTElMCMGA1UEAxMcRW50cnVzdCBFQ0MgRGVtb25zdHJhdGlvbiBDQTAe // Fw0xMTAxMjcyMDQ5NTRaFw0zNjAxMjcyMTE5NTRaMG0xCzAJBgNVBAYTAlVTMRYw // FAYDVQQKEw1FbnRydXN0LCBJbmMuMR8wHQYDVQQLExZGb3IgVGVzdCBQdXJwb3Nl // cyBPbmx5MSUwIwYDVQQDExxFbnRydXN0IEVDQyBEZW1vbnN0cmF0aW9uIENBMHYw // EAYHKoZIzj0CAQYFK4EEACIDYgAEhCWBpuJuzvRtQyibkcbCj7EkcwAqS2EqRQ/Q // ntroTdRM2SssEN4TruTxtwcY/7lR64L6Tfjz3+ujrfjNFss3EWVpUlbOJ+xHC3xH // PteNyAGZtHbZO3tVuhP6yX6dFqCCo4GLMIGIMCsGA1UdEAQkMCKADzIwMTEwMTI3 // MjA0OTU0WoEPMjAzNjAxMjcyMTE5NTRaMAsGA1UdDwQEAwIBBjAfBgNVHSMEGDAW // gBQkBUvhZIIa+AnM+3h5Ifpw5pMy6jAdBgNVHQ4EFgQUJAVL4WSCGvgJzPt4eSH6 // cOaTMuowDAYDVR0TBAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAyAhA70OIb6lb // fN6kOTQloHyCLmihNK+PT5wOuaMR//KSQP2c/H18YhDYnlwMxF9fAjEA0URaJOXM // F0qwdvS2rm7N5PWMLc/4BbeOZyZ94XJiG5u96iTgp6N9JI0MMmCQE87N // -----END CERTIFICATE----- CkPfxW_Dispose(pfx); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.