Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.asciidoc
Octocat-spinner-32 keychain_manager.gemspec
README.asciidoc

//// 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.

Purpose

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 simply wraps openssl and 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.

Testing

Verify that the tests pass on your machine. This was tested on Mac OS X 10.7 (Lion) using Ruby 1.9.2.

ruby test/keychain_test.rb

Usage

Install:
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 = 'jprichardson@gmail.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.
Note
You must upload the PEM_FILE to your server so that our backend push notification app can access it.

License

Copyright (c) 2011, JP Richardson

Tri-licensed: GPL v2, LGPL v2, MIT

Something went wrong with that request. Please try again.