Skip to main content

A Python API for Mac OS X Keychain, port of https://github.com/jprichardson/keychain_manager

Project description

https://badge.fury.io/py/keychain_manager.png https://pypip.in/d/keychain_manager/badge.png

A Python api for Mac OS X Keychain. It is a port of https://github.com/jprichardson/keychain_manager

  • Free software: BSD license

Getting started

To install the package do:

pip install keychain-manager

Usage

Example of generating Apple Push Certificate

from keychain_manager import KeychainManager
import os.path

USER = 'youremail@example.com'
# let's choose a keychain name, so we won't pollute the 'login' keychain
KEYCHAIN = 'apple_push_keychain'
# this is where the file aps_production_identity.cer will be downloaded
YOUR_DOWNLOADS_DIR = os.path.expanduser('~/Downloads/')

RSA_FILE = '/tmp/myrsa.key'
KeychainManager.generate_rsa_key(RSA_FILE)

CERT_FILE = '/tmp/CertificateSigningRequest.certSigningRequest'
# 'US' is the country abbreviation.
KeychainManager.generate_cert_request(USER, 'US', RSA_FILE, CERT_FILE)

kcm = KeychainManager(KEYCHAIN)
if kcm.exists():
    kcm.delete()
kcm.create()

kcm.import_rsa_key(RSA_FILE)

# now from your browser, you'll have downloaded a file from Apple
# typically named: aps_production.cer
kcm.import_apple_cert(os.path.join(YOUR_DOWNLOADS_DIR, 'aps_production.cer'))

P12_FILE = '/tmp/push_prod.p12'
kcm.export_identities(P12_FILE)

PEM_FILE = '/tmp/push_prod.pem'
KeychainManager.convert_p12_to_pem(P12_FILE, PEM_FILE)

kcm.delete()

Tests

Tests are running on the Mac OS X only, since we need to have actualy Keychain Manager. Just clone the repo on your Mac computer and run:

python setup.py test

History

0.1.0 (2013-09-11)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keychain_manager-0.1.3.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file keychain_manager-0.1.3.tar.gz.

File metadata

File hashes

Hashes for keychain_manager-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2d0fe40d20eab3450b6aa4431ff8d911557f9e70e2a601b73c2d9311b2df4434
MD5 f23940772590b6c8e0fdfe0dcc640d49
BLAKE2b-256 f16d143dad2fa187e18cb5bb76413f3a47fccbc014b13fd6bab28d25f949fb21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page