Apple Push Notificações - Conexões baseadas em certificado para APNs (Parte 4/4)

· Recursos

No latest entry blog about Apple Push Notificações, I show how use certificates para autenticar against Apple Push Servers.

Primeiro enter em your developer account e create um novo certificate para serviço Apple Push Notificação

Once you have downloaded your certificate, o sgcWebSockets HTTP/2 client permite use 2 security IOHandlers (somente para windows, para other personalities somente openSSL é suportado).

OpenSSL 

If you use openSSL, você deve deploy o openSSL libraries com your application. Before set o certificate com o TsgcHTTP2Client, first this certificate deve ser converted para PEM format because openSSL doesn't permitir import P12 certificates directly.

Use o following commands para convert um single P12 certificate para um certificate em PEM format e um chave privada file

create PEM certificate file

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


Create Chave privada file

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


Once you have your certificate e chave privada em PEM format, você pode configure o TsgcHTTP2Client como segue.

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 precisa deploy any libraries e o certificate downloaded um partir de Apple pode ser directly imported sem o need de um previous conversion para 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;