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 to Encrypted PEMLoads a PFX (PKCS12) and converts to encrypted PEM.
#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; pfx = CkPfxW_Create(); success = CkPfxW_LoadPfxFile(pfx,L"qa_data/pfx/myCert.pfx",L"secret"); 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"myPemPassword"; strPem = CkPfxW_toPemEx(pfx,extendedAttrs,noKeys,noCerts,noCaCerts,encryptAlg,pemPassword); wprintf(L"%s\n",strPem); // Sample output: // // -----BEGIN ENCRYPTED PRIVATE KEY----- // MIIFLzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIUTSIiX9LffYCAggA // ... // ... // ... // JHIkvQ0sld9EIyKhqG2ep+H7V6n6CcQp9sQx1VGgvOQjK9Q= // -----END ENCRYPTED PRIVATE KEY----- // -----BEGIN CERTIFICATE----- // MIIFRjCCBC6gAwIBAgIRALgZeKhNjDgwdOQ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oFCg // ToZMaHR0cDovL2NybC5jb21vZG9jYS5jb20vQ09NT0RPU0hBMjU2Q2xpZW50QXV0 // aGVudGljYXRpb25hbmRTZWN1cmVFbWFpbENBLmNybDCBkAYIKwYBBQUHAQEEgYMw // gYAwWAYIKwYBBQUHMAKGTGh0dHA6Ly9jcnQuY29tb2RvY2EuY29tL0NPTU9ET1NI // QTI1NkNsaWVudEF1dGhlbnRpY2F0aW9uYW5kU2VjdXJlRW1haWxDQS5jcnQwJAYI // KwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmNvbW9kb2NhLmNvbTAiBgNVHREEGzAZgRdz // dXBwb3J0QGNoaWxrYXRzb2Z0LmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAPSLQObU3 // eU+vgmydxUftZo41OBhzGz0IiN8Hqr1mBejr26Gts3QrndN8JzOwGEPQvf7d7fRe // lMOd8+a6DfDm7Dbr5SwzqFti1xSe29Zj2IMxlDRYRW/ODuCfSeixl7nvilBdgiGG // +Bb0wrGLq5/UeV4xP5vvtDbcWdDED0shc30Kwp5FIYbU2HJ/9gcU/0ZZEA/ml0r+ // Q8XDgVeSe/gLNvIjsQBxwbhrdQm911iNEFY9B33rYwqMnVuKc3OgetTxx6V6hxLz // jed1eLsqxx3Lag4oaSiVsoNjyXvvvaJ1MGwEKM+Pi98w9awlSLnBLYvM+5N1NvsJ // TUUKcT17pt3C5w== // -----END CERTIFICATE----- // -----BEGIN CERTIFICATE----- // MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU // MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs // IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 // MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux // FDASBgNVBAoTC0FkZFRydXN0IEFC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YqZEX // c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a // mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= // -----END CERTIFICATE----- // -----BEGIN CERTIFICATE----- // MIIErzCCA5egAwIBAgIRAOAjyxUSg1OJrWFuelRnayEwDQYJKoZIhvcNAQELBQAw // bzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1B // ZGRUcnVzdCBFeHRlcm5hbCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3Qg // RXh0ZXJuYWwgQ0EgUm9vdDAeFw0xNDEyMjIwMDAwMDBaFw0yMDA1MzAxMDQ4Mzha // MIGbMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAw // DgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01PRE8gQ0EgTGltaXRlZDFBMD8G // A1UEAxM4Q09NT0RPIFNIQS0yNTYgQ2xpZW50IEF1dGhlbnRpY2F0aW9uIGFuZCBT // ZWN1cmUgRW1haWwgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCJ // sQ3aelMZTnBSHbxWpgYmt7hJ4JbnUavx8FoTSRWjtIwbYLx6UUKneYykIt8XYU6R // 1XYjChTTSgJ/th0JgG6lBD3ZursW/qGHqS5DUkMWfK8yUMimT1rpCNjPkyWce4jo // MGTmpPhWgP0qJBQzF5msROVpi6NGBkvCM9TpQJ8GsLGsk0C5tQiTOpwqU6MQ2z0g // YTxVA47ZTnYlAiEp+qN8cXZP7uFfgen7VIDbw3s1UreE3iI9LDAtMX9ZvVI3sDNp // LUPr+tal8Zd3Z1GM2e4n67ylBzh2jKSpOP/fjPUDrEm+yvdzmToPMquclToTPQ5G // Old0YVC+xkA/y+Tin6IhAgMBAAGjggEXMIIBEzAfBgNVHSMEGDAWgBStvZh6NLQm // 9/rEJlTvA73gJMtUGjAdBgNVHQ4EFgQUkmFrguGioKpP7GfxwqP3tIAAwewwDgYD // VR0PAQH/BAQDAgGGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0lBBYwFAYIKwYB // BQUHAwIGCCsGAQUFBwMEMBEGA1UdIAQKMAgwBgYEVR0gADBEBgNVHR8EPTA7MDmg // N6A1hjNodHRwOi8vY3JsLnVzZXJ0cnVzdC5jb20vQWRkVHJ1c3RFeHRlcm5hbENB // Um9vdC5jcmwwNQYIKwYBBQUHAQEEKTAnMCUGCCsGAQUFBzABhhlodHRwOi8vb2Nz // cC51c2VydHJ1c3QuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQAbKm6sVcE6q4jF2O3N // VfOqa2ErwAkQI5kPxWZqb7H1tLV3Xg8CYQDffQX+ErOkgIAA/PsdW2pyAgpBvAW6 // wVjVJsLq1U2E+/6CmM9YG+MiY5xS+LsFNqt9WKXeqztj5drVc+/s4Pt74qP/8EIj // nMq2jU0+5EsYA7KoLdTYu0JLkGmFENumNzToe+ABEKWcyjrHn0+ING6KZdAairup // 3MrKNtH0/MJkKTWv1rGncRHSA0Oxjz6a7J4yU/R2ksqGNAe5LMrmHErYmQ3BhuKQ // kvtaQmojIRDpZcf11bt+6oyFIAJi6tE6ByxZxZkz8jiJ5bbpFnofeRT2ShAaJvp8 // ivub // -----END CERTIFICATE----- // CkPfxW_Dispose(pfx); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.