Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

C Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(C) Convert PEM to PKCS12 / PFX

Converts a PEM containing private key(s) and certificates, with extended properties, into a PKCS12 / PFX. A PEM with extended properties looks like this:

Bag Attributes
    localKeyID: 01 00 00 00
    friendlyName: le-1671821e-a2cd-4772-b0e4-5258de05117d
    Microsoft CSP Name: Microsoft RSA SChannel Cryptographic Provider
Key Attributes
    X509v3 Key Usage: 10
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIMudDGh+tZYQCAggA
MB0GCWCGSAFlAwQBAgQQ4OSsxHAEu4mVhgcA9L7shASCBNCrBP0NPFTO45uw5Myh
...
XZhOf3kcRPT9npxPV1Ez6uEiug==
-----END ENCRYPTED PRIVATE KEY-----
Bag Attributes
    localKeyID: 01 00 00 00
    friendlyName: Chilkat Software
    1.3.6.1.4.1.311.17.3.20: 7C 94 55 D2 71 0B E4 3C D6 BD D8 06 D9 BD A8 EF 36 63 25 05
subject=/OU=Domain Control Validated/CN=www.chilkatsoft.com
issuer=/C=US/ST=Arizona/L=Scottsdale/O="GoDaddy.com, Inc."/OU=http://certs.godaddy.com/repository//CN=Go Daddy Secure Certificate Authority - G2
-----BEGIN CERTIFICATE-----
MIIFMDCCBBigAwIBAgIHJ6r9KpNgnzANBgkqhkiG9w0BAQsFADCBtDELMAkGA1UE
BhMCVVMxEDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAY
...
wXUiw2o3eiSCmh4/iF1hwCGbCR2Mx/JhdeEY6ytITDM1tiG4
-----END CERTIFICATE-----
Bag Attributes
    friendlyName: Go Daddy Root Certificate Authority – G2
    1.3.6.1.4.1.311.17.3.29: 70 25 3F BC BD E3 2A 01 4D 38 C1 99 30 98 AD 99
    1.3.6.1.4.1.311.17.3.20: 3A 9A 85 07 10 67 28 B6 EF F6 BD 05 41 6E 20 C1 94 DA 0F DE
    1.3.6.1.4.1.311.17.3.98: 45 14 0B 32 47 EB 9C C8 C5 B4 F0 D7 B5 30 91 F7 32 92 08 9E 6E 5A 63 E2 74 9D D3 AC A9 19 8E DA
    1.3.6.1.4.1.311.17.3.83: 30 23 30 21 06 0B 60 86 48 01 86 FD 6D 01 07 17 03 30 12 30 10 06 0A 2B 06 01 04 01 82 37 3C 01 01 03 02 00 C0
    1.3.6.1.4.1.311.17.3.9: 30 52 06 08 2B 06 01 05 05 07 03 01 06 08 2B 06 01 05 05 07 03 02 06 08 2B 06 01 05 05 07 03 03 06 08 2B 06 ...
subject=/C=US/ST=Arizona/L=Scottsdale/O="GoDaddy.com, Inc."/CN=Go Daddy Root Certificate Authority - G2
-----BEGIN CERTIFICATE-----
MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx
EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT
...

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <C_CkPem.h>
#include <C_CkPfx.h>

void ChilkatSample(void)
    {
    HCkPem pem;
    const char *password;
    BOOL success;
    const char *pemContent;
    HCkPfx pfx;

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // The Chilkat PEM class was introduced in v9.5.0.49.  
    // It requires the bundle to be unlocked, as shown above.
    pem = CkPem_Create();

    // Load the PEM from a file.
    // If the PEM is encrypted, provide a password.  Otherwise pass an empty string for the password.
    password = "myPassword";
    success = CkPem_LoadPemFile(pem,"../myPemFiles/myPem.pem",password);
    if (success != TRUE) {
        printf("%s\n",CkPem_lastErrorText(pem));
        CkPem_Dispose(pem);
        return;
    }

    // Note: If the app already has the PEM pre-loaded in a string variable, then load it 
    // by calling LoadPem instead.  
    pemContent = "... the PEM contents ...";
    success = CkPem_LoadPem(pem,pemContent,password);
    // Check for success as before..

    // Convert to a PFX object:
    pfx = CkPem_ToPfx(pem);
    if (CkPem_getLastMethodSuccess(pem) == FALSE) {
        printf("%s\n",CkPem_lastErrorText(pem));
        CkPem_Dispose(pem);
        return;
    }

    // Save the PFX to a file:
    success = CkPfx_ToFile(pfx,"myPfxPassword","../myPfxFiles/myPfx.pfx");
    if (success != TRUE) {
        printf("%s\n",CkPfx_lastErrorText(pfx));
        CkPem_Dispose(pem);
        return;
    }

    CkPfx_Dispose(pfx);


    CkPem_Dispose(pem);

    }

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.