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

· 기능

Apple Push 알림에 관한 최신 블로그에서 Apple Push 서버에 인증하기 위해 인증서를 사용하는 방법을 보여드릴게요.

먼저 개발자 계정에 들어가 Apple Push Notification 서비스용 새 인증서를 만드세요.

인증서를 다운로드한 후icate, the sgcWebSockets HTTP/2 client allows to use 2 security IOHandlers (only for windows, for other personalities only openSSL is supported).

OpenSSL 

openSSL을 사용한다면 애플리케이션과 함께 openSSL 라이브러리를 배포해야 해요. TsgcHTTP2Client에 인증서를 설정하기 전에, openSSL은 P12 인증서를 직접 가져올 수 없기 때문에 먼저 이 인증서를 PEM 형식으로 변환해야 해요.

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 

SChannel을 사용한다면 별도의 라이브러리를 배포할 필요가 없고, Apple에서 다운로드한 인증서를 PEM 형식으로 사전 변환할 필요 없이 바로 가져올 수 있어요.

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