//// Github AsciiDoc renderer sucks bad!
Ruby Gem Mac OS X Keychain Manager
This gem aids your ruby scripts by providing access to the Mac OS X Keychain Access.
I needed a way to generate 100+ Apple push notification certificates for my iOS apps. Using the
Mac OS X command
security, I was able to automate the generation of certificates. This gem
security command line utilities.
As of now, this gem only contains code relevant to the generation of keys and certificates for iOS development. Of course, this could easily be expanded to include other areas.
Verify that the tests pass on your machine. This was tested on Mac OS X 10.7 (Lion) using Ruby 1.9.2.
gem install keychain_manager
Reminder, this gem was used to automate the creation of Apple iOS push notification certificates. The following demonstrates this process.
//// [source,ruby] must comment for Github’s crappy renderer.
USER = 'email@example.com' KEYCHAIN = 'apple_push_keychain' #this can be anything, we just don't want to pollute the 'login' keychain YOUR_DOWNLOADS_DIR = '' # you must set this, this is where the file aps_production_identity.cer exists RSA_FILE = '/tmp/myrsa.key' KeychainManager.generate_rsa_key(RSA_FILE) CERT_FILE = '/tmp/CertificateSigningRequest.certSigningRequest' KeychainManager.generate_cert_request(USER, 'US', CERT_FILE) #'US' is the country abbreviation. kcm = KeychainManager.new(KEYCHAIN) kcm.delete if kcm.exists? kcm.create kcm.import_rsa_key(RSA_FILE) #now from your browser, you'll have downloaded a file from Apple typically named: aps_production_identity.cer kcm.import_apple_cert(File.join(YOUR_DOWNLOADS_DIR, '/aps_production_identity.cer')) P12_FILE = '/tmp/push_prod.p12' kcm.export_identites(P12_FILE) PEM_FILE = '/tmp/push_prod.pem' KeychainManager.convert_p12_to_pem(P12_FILE, PEM_FILE) kcm.delete #Now upload the PEM_FILE to your server.
|You must upload the PEM_FILE to your server so that our backend push notification app can access it.|
Copyright (c) 2011, JP Richardson
Tri-licensed: GPL v2, LGPL v2, MIT