Apple Push Notifications - Certificates Based Connections to APNs (Part 4/4)

In the latest entry blog about Apple Push Notifications, I show how use certificates to authenticate against Apple Push Servers.

First enter in your developer account and create a new certificate for Apple Push Notification service

Once you have downloaded your certificate, the sgcWebSockets HTTP/2 client allows to use 2 security IOHandlers (only for windows, for other personalities only openSSL is supported).

  • OpenSSL
  • SChannel (only for windows)

OpenSSL 

If you use openSSL, you must deploy the openSSL libraries with your application. Before set the certificate with the TsgcHTTP2Client, first this certificate must be converted to PEM format because openSSL doesn't allow to import P12 certificates directly.

Use the following commands to convert a single P12 certificate to a certificate in PEM format and a private key file

create PEM certificate file

 openssl pkcs12 -in INFILE.p12 -out OUTFILE.crt -nokeys


Create Private Key file

 openssl pkcs12 -in INFILE.p12 -out OUTFILE.key -nodes -nocerts


Once you have your certificate and private key in PEM format, you can configure the TsgcHTTP2Client as follows.

oHTTP := TsgcHTTP2Client.Create(nil);
oHTTP.TLSOptions.IOHandler := iohOpenSSL;
oHTTP.TLSOptions.CertFile := 'certificate_file.pem';
oHTTP.TLSOptions.KeyFile := 'private_key.pem';
oHTTP.TLSOptions.Password := 'certificate password';
oHTTP.TLSOptions.Version := tls1_2; 

SChannel 

If you use SChannel there is no need to deploy any libraries and the certificate downloaded from Apple can be directly imported without the need of a previous conversion to PEM format.

oHTTP := TsgcHTTP2Client.Create(nil);
oHTTP.TLSOptions.IOHandler := iohSChannel;
oHTTP.TLSOptions.CertFile := 'certificate_file.p12';
oHTTP.TLSOptions.Password := 'certificate password';
oHTTP.TLSOptions.Version := tls1_2; 
×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

sgcWebSockets 4.4.9
Apple Push Notifications - Token Based Connections...

Related Posts