Visual C++ Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

Verify SSL Server Certificate

Demonstrates how to connect to an SSL server and verify its SSL certificate.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
#include <CkSocket.h>
#include <CkCert.h>

void ChilkatSample(void)
    {
    CkSocket socket;

    bool success;
    success = socket.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        printf("Failed to unlock component\n");
        return;
    }

    bool ssl;
    ssl = true;
    long maxWaitMillisec;
    maxWaitMillisec = 20000;

    //  The SSL server hostname may be an IP address, a domain name,
    //  or "localhost".
    const char * sslServerHost;
    sslServerHost = "www.paypal.com";
    long sslServerPort;
    sslServerPort = 443;

    //  Connect to the SSL server:
    success = socket.Connect(sslServerHost,sslServerPort,ssl,maxWaitMillisec);
    if (success != true) {
        printf("%s\n",socket.lastErrorText());
        return;
    }

    CkCert *cert = 0;

    bool bExpired;
    bool bRevoked;
    bool bSignatureVerified;
    bool bTrustedRoot;

    cert = socket.GetSslServerCert();
    if (!(cert == 0 )) {

        printf("Server Certificate:\n");
        printf("Distinguished Name: %s\n",cert->subjectDN());
        printf("Common Name: %s\n",cert->subjectCN());
        printf("Issuer Distinguished Name: %s\n"
            ,cert->issuerDN());
        printf("Issuer Common Name: %s\n",cert->issuerCN());

        bExpired = cert->IsExpired();
        bRevoked = cert->get_Revoked();
        bSignatureVerified = cert->get_SignatureVerified();
        bTrustedRoot = cert->get_TrustedRoot();

        printf("Expired: %d\n",bExpired);
        printf("Revoked: %d\n",bRevoked);
        printf("Signature Verified: %d\n",bSignatureVerified);
        printf("Trusted Root: %d\n",bTrustedRoot);

        delete cert;
    }

    //  Close the connection with the server
    //  Wait a max of 20 seconds (20000 millsec)
    socket.Close(20000);


    }

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

Mail Component · .NET Mail Component · XML Parser