Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

C# UWP/WinRT Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
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)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(C# UWP/WinRT) Load Certificate from PFX (PKCS#12)

Loads a digital certificate (and private key, if available) from a PFX file.(also known as PKCS#12)

Chilkat Universal Windows Platform (UWP) / WinRT Downloads

Chilkat for the Universal Windows Platform (UWP)

Chilkat.Cert cert = new Chilkat.Cert();

bool success;

//  Load from the PFX file
string pfxFilename = "/Users/chilkat/testData/pfx/chilkat_ssl_pwd_is_test.pfx";
string pfxPassword = "test";

//  A PFX typically contains certificates in the chain of authentication.
//  The Chilkat cert object will choose the certificate w/
//  private key farthest from the root authority cert.
//  To access all the certificates in a PFX, use the
//  Chilkat certificate store object instead.
success = cert.LoadPfxFile(pfxFilename,pfxPassword);
if (success != true) {
    Debug.WriteLine(cert.LastErrorText);
    return;
}

//  Get some information about the digital certificate,
//  then get the private key...

//  DN = "Distinguished Name"
Debug.WriteLine("SubjectDN:" + cert.SubjectDN);

Debug.WriteLine("Common Name:" + cert.SubjectCN);
Debug.WriteLine("Issuer Common Name:" + cert.IssuerCN);

Debug.WriteLine("Serial Number:" + cert.SerialNumber);

//  Now for the private key...
Chilkat.PrivateKey privKey = null;

privKey = cert.ExportPrivateKey();
if (privKey == null ) {
    Debug.WriteLine(cert.LastErrorText);
    return;
}

//  The private key object may be used in any Chilkat methods
//  (in other objects/classes) that expect a private key argument.

//  In this case, save the private key to a PKCS8 Encrypted PEM format file:
string pemPassword = "secret";
string pemPath = "/Users/chilkat/testData/pem/chilkat_privKey.pem";
success = privKey.SavePkcs8EncryptedPemFile(pemPassword,pemPath);
if (success != true) {
    Debug.WriteLine(privKey.LastErrorText);

    return;
}

Debug.WriteLine("Private key saved to PKCS8 Encrypted PEM...");

 

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