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# Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(C#) CAdES BES Detached Signature

Demonstrates how to create a CAdES BES detached signature file (.p7s).

Chilkat .NET Downloads

Chilkat .NET Assemblies

Chilkat for .NET Core

Chilkat for Mono

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

Chilkat.Crypt2 crypt = new Chilkat.Crypt2();

// Use a digital certificate and private key from a PFX file (.pfx or .p12).
string pfxPath = "/Users/chilkat/testData/pfx/acme.pfx";
string pfxPassword = "test123";

Chilkat.Cert cert = new Chilkat.Cert();
bool success = cert.LoadPfxFile(pfxPath,pfxPassword);
if (success != true) {
    Debug.WriteLine(cert.LastErrorText);
    return;
}

// Tell the crypt component to use this cert.
success = crypt.SetSigningCert(cert);
if (success != true) {
    Debug.WriteLine(crypt.LastErrorText);
    return;
}

// The CadesEnabled property applies to all methods that create PKCS7 signatures. 
// To create a CAdES-BES signature, set this property equal to true. 
crypt.CadesEnabled = true;

// We can sign any type of file, creating a .p7s as output:
string inFile = "/Users/chilkat/testData/pdf/sample.pdf";
string sigFile = "/Users/chilkat/testData/p7s/sample.p7s";

// Create the detached CAdES-BES signature:
success = crypt.CreateP7S(inFile,sigFile);
if (success == false) {
    Debug.WriteLine(crypt.LastErrorText);
    return;
}

success = crypt.VerifyP7S(inFile,sigFile);
if (success == false) {
    Debug.WriteLine(crypt.LastErrorText);
    return;
}

Debug.WriteLine("Success!");

 

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