Search code examples
macoskeychainpackagemaker

Access KeyChain from PackageMaker


Is it possible to store certificates into the key chain as part of installation created with PackageMaker? I would like to provide an installation which inserts the certificates into the key chain on Mac OS X.


Solution

  • I've founded the solution for importing certificates as a part of installation. The solution includes performing following steps:

    1. add certs folder (contains the certificates we wish to import) into the installation. The certs folder is extracted on the specified path (defined as CERT_PATH variable)
    2. create a shell script (also included into the installation to be extracted), which performs the import of certificates into the keychain. The script looks similar to:

      CERT_PATH = "/Applications/MyApp/certs"

      security add-certificates $CERT_PATH/mycert1.crt

      security add-certificates $CERT_PATH/mycert2.crt

    The script is called postflight (more about Package Maker and scripts at Using PackageMaker to run a script on install)