node.js2012. 10. 31. 10:41

It’s coming up to a year since we launch our server monitoring iPhone application and so our Apple push notification SSL certificate is expiring in a few weeks. It is necessary to renew it and install the new certificate on our servers so we can continue sending push notifications for server alerts, and this quick post will take you through the steps.

You can generate a new certificate without revoking the old one, and use them simultaneously to ensure they are working before revoking the old one.

1) Log in

iPhone Portal App IDs

Log into the Apple iPhone Developer website and click the iPhone Provisioning Portal link. From the left menu, click on App IDs and then Configure next to the app you want to regenerate the certificate for. You’ll see your existing certificates and the option to generate a new one. Click the Configure button to launch the wizard.

2) Generate a CSR

I used the CSR I generated for the original APNS certificate but you can generate a new one by following the instructions in the wizard.

3) Generate the certificate

iPhone Portal Generate

After uploading the CSR, the wizard will generate your new certificate. The name will show up as your username rather than what you specify in the CSR. Download it to your system, it will be called aps_production_identity.cer. Double click it to import it into your Keychain.

4. Export certificates / keys

Launch Keychain Assistant from your local Mac and from the login keychain, filter by the Certificates category. You will see an expandable option called “Apple Development Push Services”. You’ll see your old certificate and the new one you just downloaded.

Click the triangle to expand the certificate. You’ll have 2 items – the certificate itself that you just expanded, and the private key that was revealed.

Keychain Export

Right click on the certificate (not the private key) “Apple Development Push Services” > Export “Apple Development Push Services ID123″. Save this as apns-prod-cert.p12 file somewhere you can access it. Then do the same with the private key and save it as apns-prod-key.p12.

For both exports, you will be asked to specify a password, then asked for your keychain password. I did not specify a password on the first prompt.

5) Convert to PEM format

These files now need to be converted to the PEM format by executing these 2 commands from the terminal:

1
2
openssl pkcs12 -clcerts -nokeys -out apns-prod-cert.pem -in apns-prod-cert.p12
openssl pkcs12 -nocerts -out apns-prod-key.pem -in apns-prod-key.p12

You will be forced to set a PEM passphrase on the second command, so execute the following command to remove it:

1
openssl rsa -in apns-prod-key.pem -out apns-prod-key-noenc.pem

6) Merge files

Finally, you need to combine the key and cert files into a apns-prod.pem file we will use when connecting to APNS:

1
cat apns-prod-cert.pem apns-prod-key-noenc.pem > apns-prod.pem

And that’s it. You can replace your existing production certificate with the one you just created, and it’ll be valid for another year. Yay.


정리를 해보자.

응용프로그램 -> 키체인 접근  프로그램을 연다.

그리고 해당 푸쉬 인증서 삼각형 세모를 누르면 개인키가 보인다.

일단 인증서만 클릭해놓고 apns-prod-cert.p12 파일로 내보낸다.

그리고 개인키만 클릭해놓고 apns-prod-key.p12 파일로 내보낸다.


그리고 터미널을 실행해서 다음과 같은 명령을 실행한다.

openssl pkcs12 -clcerts -nokeys -out apns-prod-cert.pem -in apns-prod-cert.p12
openssl pkcs12 -nocerts -out apns-prod-key.pem -in apns-prod-key.p12

apns-prod-key.pem 을 만들때 암호를 지정할수밖에 없는데
이제 그 암호를 제거해서 보자. 다음 명령을 입력한다.

openssl rsa -in apns-prod-key.pem -out apns-prod-key-noenc.pem

이제
인증서 파일과 키 파일을 결합하면 된다.

cat apns-prod-cert.pem apns-prod-key-noenc.pem > apns-prod.pem

를 입력하자.


ps. 하지만 실상 node.js apns 에서 필요한 파일은
apns-prod-cert.pem 파일과 apns-prod-key-noenc.pem 파일만 있으면 된다.

수고했다.


'node.js' 카테고리의 다른 글

node.js 에서 debugger 를 사용해보자.  (0) 2012.10.26
node.js 설치 방법 및 샘플  (0) 2012.07.09
Posted by 다오나무
node.js2012. 10. 26. 13:30

cloud9 을 통합환경으로 쓰고 있는데

syntax-highlighting만 겨우 지원하는 무거운 노트패드 같다.
의도와는 다르게 디버깅(watch, breakpoint 등)이 잘 돌아가지 않고 있다.
node-inspector 를 쓰면 좋다.
chrome 의 디버거와 거의 똑같이 생겨서 익숙하다.

먼저 설치
$ npm install node-inspector

실행해보자.
디버깅을 위한 거니까 server 기동도 디버그 모드로 띄운다.
$ node --debug server.js

그리고 inspector 를 띄운다.
$ node-inspector --web-port=3001
visit http://0.0.0.0:3001/debug?port=5858 to start debugging

친절하게 안내해준다.
디버그 포트는 기본이 5858 이니까 혹여 변경했다면 알아서 인자를 바꿔주자.

크고 아름답다.

'node.js' 카테고리의 다른 글

node.js용 iOS 푸쉬 인증서를 생성해 보자.  (0) 2012.10.31
node.js 설치 방법 및 샘플  (0) 2012.07.09
Posted by 다오나무
node.js2012. 7. 9. 23:05

이제 node.js 를 시작해 보려 합니다.

트랜드에 조금 뒤쳐졌지만.. 시작해 봅시다.

왜 node.js에 관심을 가지게 되었는가 부터 배경을 설명하면..

간단한 설치 및 유연한 속도 또한 확장성 부분에서 뛰어날 수 있다라는 관점..

특히나 js 를 사용한다는 점.. 시스템을 접근해서 만질 수 있다는 점.. 여러가지 메리트가 있더라고요.

자 그럼 설치 해 보고 시작해 봅시다.

저는 우분투를 사용하기 때문에, 우분투 리눅스 위주로 작성합니다.

설치방법: 일단 apt-get 을 이용해 필요한 요소를 설치 합니다.

> sudo apt-get install g++ curl libssl-dev apache2-utils

> sudo apt-get install git-core

기본 설치는 완료 했고요.

이제 실제 node.js 라이브러리를 설치 합니다.

nodejs.org 로 가서 최신 버전을 받는다.

> wget http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz

> cd node-v0.6.14

> ./configure

> make

> sudo make install

샘플코드

 test_node.js 파일을 만드시고

var http = require('http');

http.createServer(function (req, res) {

  res.writeHead(200, {'Content-Type': 'text/plain'});

  res.end('Hello Node.js\n');

}).listen(8282, "127.0.0.1");

console.log('Server running at http://127.0.0.1:8282/');

이렇게 넣으시고.. 커맨드 창에서

> node test_ndoe.js

이렇게 하시고 wget 127.0.0.1:8282 라고 하시면 확인이 가능합니다.

따로 ip 지정 안하시면 외부 웹으로 접근도 가능합니다.:)

그럼 몇 가지 샘플을 한 번 더 볼까요.

hello.js

// helloworld1.js

var sys = require("sys")

setTimeout(function() {

    sys.puts("world");

}, 2000);

sys.puts("hello");


// helloworld_sigint.js

puts = require("sys").puts;

setInterval(function() {

    puts("hello");

}, 500); 

process.addListener("SIGINT", function() {

    puts("good-bye");

    process.exit(0);

});


// hello_tcp.js

var tcp = require("net");

tcp.createServer(function(c) {

     c.write("hello!\n");

    c.end();

 }).listen(8000);


// hello_html.js

var http = require("http");

http.createServer(function(req, res) {

    res.writeHead(200, {"Content-Type": "text/plain"});

    res.write("Hello\r\n");

    res.write("World\r\n");

    res.end();

}).listen(8080);


// hello_stream.js

var http = require("http");

http.createServer(function(req, res) {

    res.writeHead(200, {"Content-Type": "text/plain"});

    res.write("Hel");

    res.write("lo\r\n");

    setTimeout(function() {

        res.write("World\r\n");

        res.end();

    }, 2000);

}).listen(8000);


응용할 만한게 참 많은 것 같다. 재미있네?

'node.js' 카테고리의 다른 글

node.js용 iOS 푸쉬 인증서를 생성해 보자.  (0) 2012.10.31
node.js 에서 debugger 를 사용해보자.  (0) 2012.10.26
Posted by 다오나무