Recently, I have just done a task to develop push notification service for a backend. Originally I thought it will be quite easy. But in the end I found myself spend quite some time to understand the server credentials needed to talk to APNS and GCM.
The one for Google Cloud Messaging is actually not that hard to follow. Just didn't go the the right pages in the beginning. And also, it seems only the owner of the Android project can enable the GCM API and generate the key. The correct place to go to generate/regenerate the key is https://console.developers.google.com/project/{project_id}/apiui/credential
The one for APNS is harder. A lot harder to start. You basically need to generate at least two sets of private keys/certificates. They are for establishing authenticated/secure connection with the APNS server/gateway. You need to first generate a Certificate Signing Request (CSR) locally on your dev machines. (Follow this post if generating on a Mac http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1). CSR can be generated purely using openssl tool too. The Mac Keychain tool is quite handy though. The tutorial in http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 post is not 100% right. After you upload you CSR and download the development and production certificate, you need to convert the private keys and the downloaded certificates into PEM format. That is all you need.
The certificate you downloaded from Apple site is in der format. You need the following command to convert it into PEM format:
openssl x509 -in aps_development.cer -inform der -out aps_development_cert.pem
For the private key, find them in your keychain and export them in p12 format. Then use this command:
openssl pkcs12 -in devkey.p12 -out dev_key.pem -nodes
The -nodes switch is NOT to encrypt the key file. So you don't need a password. Since we are generating the key for server dedeployment. It is better not to have a password. This command will put both the certificate and private key in one PEM file. If you just want the key without certificate.
Use this command:
openssl pkcs12 -nocerts -in devkey.p12 -out dev_key.pem -nodes
Saturday, March 14, 2015
Sunday, December 21, 2014
Enable Remote Desktop login from command line
Have you ever forget to turn on remote desktop on a Window machine and then you cannot remotely do your admin or development work? I am sure there must be a time you wish there is a ssh login shell for your windows machine. As all hackers do, I believe just give me a shell, and I can move the earth. So I spend some time to research the way to turn on remote desktop from and windows command line shell. Here is the post:
http://www.windows-commandline.com/enable-remote-desktop-command-line/
Here is the command:
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
http://www.windows-commandline.com/enable-remote-desktop-command-line/
Here is the command:
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
Sunday, June 20, 2010
Convert audios on Mac
Nowadays, on the Internet, there are really diverse formats of audio files. I often
find the need to convert files from one format to another. For naive users, this
can be a challenging task. But actually it can be a trivial script or set of commands
if you know how to tap the power of all the marvelous open source tools, esp.
mplayer and lame, etc.
These two links show the basic example.
http://www.linuxquestions.org/questions/linux-general-1/converting-m4a-to-mp3-170553/
http://gimpel.gi.funpic.de/wiki/index.php?title=Howto:convert_aac/mp4_to_wav/mp3/ogg_on_Linux
You can also convert other formats, like flash, too, as long as you have all the plugins.
The Mac specific build of MPlayer is here:
http://mplayerosxext.googlecode.com/files/MPlayer-OSX-Extended_rev13.zip
find the need to convert files from one format to another. For naive users, this
can be a challenging task. But actually it can be a trivial script or set of commands
if you know how to tap the power of all the marvelous open source tools, esp.
mplayer and lame, etc.
These two links show the basic example.
http://www.linuxquestions.org/questions/linux-general-1/converting-m4a-to-mp3-170553/
http://gimpel.gi.funpic.de/wiki/index.php?title=Howto:convert_aac/mp4_to_wav/mp3/ogg_on_Linux
You can also convert other formats, like flash, too, as long as you have all the plugins.
The Mac specific build of MPlayer is here:
http://mplayerosxext.googlecode.com/files/MPlayer-OSX-Extended_rev13.zip
Thursday, January 28, 2010
Misc tricks on Windows Development
Another two trick I discovered recently:
1. How to unlock a file/directory that is locked by a unfriendly process?
On Windows, you cannot delete or rename (move) a file/directory if it is
locked by a process. There is a way to do it (CreateRemoteThread). See
http://social.msdn.microsoft.com/Forums/en-SG/csharpgeneral/thread/9e2044c5-ae5d-4552-a335-01cc567dfc58. But if I want a tool to do it, then,
Unlocker is all you need.
2. How to check memory leak on Windows?
Well, using MSVC runtime, you can use the crtdbg interface. The post is here:
http://msdn.microsoft.com/en-us/library/e5ewb1h3%28VS.80%29.aspx
1. How to unlock a file/directory that is locked by a unfriendly process?
On Windows, you cannot delete or rename (move) a file/directory if it is
locked by a process. There is a way to do it (CreateRemoteThread). See
http://social.msdn.microsoft.com/Forums/en-SG/csharpgeneral/thread/9e2044c5-ae5d-4552-a335-01cc567dfc58. But if I want a tool to do it, then,
Unlocker is all you need.
2. How to check memory leak on Windows?
Well, using MSVC runtime, you can use the crtdbg interface. The post is here:
http://msdn.microsoft.com/en-us/library/e5ewb1h3%28VS.80%29.aspx
NTP on Windows
Time is important. Very! Few Windows users really care about
whether there computer clock is right or not. But as an IT professional,
we all know very well that. The time is IMPORTANT.
Recently, I have been annoyed by the fact that my Thunderbird order
my emails wrongly because of my local Windows machine's time is not
correct. Well the time stamp in the email is the client-side's time stamp,
not the server-side one. What can I do? I think I can just ensure that
at least, my machine has the correct time. I know very well how to set up
a NTP client in the *NIX world. But how to do it on Windows? I didn't find
a way from the GUI (Control Panel). So I Google researched a bit.
Below is the excerpt from the Microsoft site:
To configure a client computer for automatic domain time synchronization
You can also get the time from specified NTP server. Just need to change
to :
w32tm /config /syncfromflags:manual /manualpeerlist:servername /update
I love command line.
whether there computer clock is right or not. But as an IT professional,
we all know very well that. The time is IMPORTANT.
Recently, I have been annoyed by the fact that my Thunderbird order
my emails wrongly because of my local Windows machine's time is not
correct. Well the time stamp in the email is the client-side's time stamp,
not the server-side one. What can I do? I think I can just ensure that
at least, my machine has the correct time. I know very well how to set up
a NTP client in the *NIX world. But how to do it on Windows? I didn't find
a way from the GUI (Control Panel). So I Google researched a bit.
Below is the excerpt from the Microsoft site:
To configure a client computer for automatic domain time synchronization
-
Open a Command Prompt.
-
Type the following command and then press ENTER:
w32tm /config /syncfromflags:domhier /update
-
Type the following command and then press ENTER:
net stop w32time
-
Type the following command and then press ENTER:
net start w32time
You can also get the time from specified NTP server. Just need to change
to :
w32tm /config /syncfromflags:manual /manualpeerlist:servername
I love command line.
Subscribe to:
Posts (Atom)