Originally Web posted Monday, 15 April 2013.
Content last modified Sunday, 27 August 2017 .

Be Your Own Certificate Authority

Create/distribute S/MIME secure email certificates for others

Without question one of the greatest challenges in terms of real-world usage of secure email is getting your correspondents to set things up on their end. People are busy and have other interests, and may not share your personal desire to securely exchange email messages unless you make it dirt-easy for them.

Fortunately, Apple seems to have considered precisely this situation! They’ve built in some very nice abilities into their Certificate Assistant software, allowing you to become your own Certificate Authority (CA) and create viable S/MIME email security credentials on behalf of other Mac users—securely and remotely—with little effort on their part.

Unfortunately, Certificate Assistant and Keychain Access and the whole security infrastructure remain a buggy minefield of GOTCHAs. I’ve done the best i can (as an uncompensated volunteer documenter) to find, track, and test various functions, but there are simply too many possible ways of doing things and too many bugs which i find hard to reproduce to provide you an iron-clad, guaranteed path to success. What lies below is my best effort, with all the workarounds i could find.


Overview

  1. Set yourself up as a Certificate Authority
  2. Let your correspondents know that you’re now a CA and ready to create certificates for them. Normally when you do this, you’ll include a configuration file which will make the process easier for them.
  3. Have each of them send you a Certificate Signing Request (CSR), which process itself securely generates their public and private key pair right there on their machine
  4. Use their CSR and your Certificate Assistant software to create their signed certificate, and send it to them

Warning: Serial Numbers Matter when you’re your own Certificate Authority! I found out the hard way that Certificate Assistant and Keychain Access will not allow more than one certificate from a given CA to share the same serial number—including the root CA certificate.

Be certain you keep track of serial numbers for all certificates issued by your CA! By default, copies of certificates you create for others are placed in your own default keychain (except in OS 10.4 Tiger), so right there we have the potential for massive conflict!

Certificate Assistant’s counter for tracking serial numbers lives in its configuration file ([Name of CA].certAuthorityConfig). The counter intermittently counts when defaults are overridden when making certificates from this CA in Certificate Assistant, on a version-specific basis:

Any certificates made with defaults overridden may not increment this counter! For this reason, carefully track all serial numbers on all certificates made by Certificate Assistant as a CA. You may need to re-do a certificate which pops out with an already-used number, overriding defaults or manually incrementing the counter in the .certAuthorityConfig (Plist format) file.


Create a Certificate Authority

The steps are nearly identical for OS 10.5 Leopard through 10.12 Sierra. Tiger differs somewhat, though not enough that i feel the need to write out separate instructions. If in doubt for any OS version, compare these instructions for those for your OS and self-signed certificates and interpolate. Here’s how it works for OS 10.8 Mountain Lion (OS 10.8.3 and its Certificate Assistant 5.0):
  1. If you would like to send out certificate invitations via email to other users immediately at the end of the setup process (not required), be certain that the email address you intend to use for your Certificate Authority is all set up and working in Mail.
  2. Launch Certificate Assistant (directly or through the Keychain Access menu of Keychain Access. Select Create a Certificate Authority….
  3. Make the basic choices, such as the name of your CA and its email address.
    Name of CA, Identity Type: Self Signed Root CA, User Certificate: S/MIME (Email), Make this CA the default is checked
    Be sure to check Let me override defaults!
  4. Set the Serial Number and the Validity Period for your CA. Note that when your CA’s certificate expires, so do all subsidiary certificates created with it, so be sure to choose a sufficiently long time for the validity period.

    There is an option (default disabled) to “Create a CA web site”. This might be useful if you’re able to set up a secure website and plan to distribute certificates to a large number of people. I did not test this option.

    There is also an option to “Sign your invitation”. This option will ensure that invitation emails you send out will be signed with one of your own pre-existing certificates (if you have any), so recipients will know that it came from you and was not altered in transit. Note that it is not an option to use the CA certificate itself for this purpose, as it has not yet been created. Even though it is shown selected in the screenshot, i do not recommend using this option. (I’ve found what i think is a better method, which i’ll explain below. You’ll sign, but not via this checkbox option. This option might also prevent interoperation with older OS X versions predating its existence, based upon limited testing i did.)

  5. If you have elected (against my advice) to sign your invitation(s) with a non-CA ID and Certificate Assistant finds you have at least one existing identity (set of certificate and key credentials for S/MIME secure email), a sheet will drop down asking you to select the identity which will be used to sign the invitation(s)(even if there is only one). Here is an example where there are several pre-existing options:

    If Certificate Assistant finds no currently existing identity it can use, instead you’ll see:
    “There are currently no identities available to sign your CA invitation. Your invitation will remain unsigned.”
  6. Fill out personal information for the CA, as you’d do for a personal self-signed certificate. This information will be part of all certificates your CA creates, as well as your own CA certificate. Consult the main article for further information if necessary.
  7. Next is the usual Key Pair window, this one for the CA itself:

    Unless you know more than me and have reason to choose otherwise, i suggest using the defaults of 2048 bit Key Size and the RSA Algorithm.
  8. You might think you have deja vu all over again when you click Continue and again see the Key Pair window. Notice that this time you’re making settings for your user’s credentials: the ones your CA will be making for them.
    Defaults: Key Size 2048 bits and Algorithm: RSA
    This information will go into the settings file on your system and to be sent to your “customers”.
  9. Next you’ll be setting up the Key Usage Extension (KUE) for this CA, if you use it.

    Believe it or not, the defaults as shown will actually work, as long as the CA certificate is not itself used for S/MIME. The general idea is that the CA certificate is reserved for only creating and signing other certificates, in which case the defaults as shown are fine. It is also OK to omit the KUE entirely, again as long as you’re not using it for S/MIME, or at least not on OS 10.12 and likely newer. (Most of my testing included the KUE for the CA, with the defaults shown and most often additionally Key Encipherment, to allow others to encrypt messages to the CA email address.)

    If you intend to use one certificate for the CA and as an end-user certificate for S/MIME email, you will need to select Key Encipherment if you choose to use this extension, as is the case for individual self-signed certificates, or omit this extension entirely (no longer recommended, since Mail for Sierra requires a valid S/MIME KUE). (I did very little testing omitting the KUE entirely for a CA certificate.)

    Note: This is currently an exercise in futility with Certificate Assistant 5.0 for Mountain Lion through El Capitan, as it has a bug. Read all about it below.
    Thankfully this bug appears fixed with the newer build of Certificate Assistant 5.0 included with OS 10.12.
  10. Since you’re also creating a template (settings) file for your CA users as well as creating your own certificate, you’ll now be presented for the KUE options for your users. The same considerations as for a self-signed KUE apply here, which is to say: be certain to additionally check Key Encipherment. If you have any doubt, please re-read the KUE information in the main article. I’m omitting a screenshot of the User KUE window as it looks exactly the same, other than its title and explanatory text (user vs. CA).
  11. Next is the Extended Key Usage Extension (EKUE) for the CA (except on Tiger. See Version Quirks):

    Interestingly, the EKUE is not included by default for the CA, and if one enables it, its default option is “Any”, which is nearly (but not exactly) the same as not having the EKUE at all… the difference being that having the EKUE set to “Any” explicitly declares any ability for the certificate, whereas having no EKUE leaves things undefined. From what i’ve read, in most cases the real-world interpretation of no EKUE is the same as having it and explicitly allowing any abilities for it. I suggest going with Apple’s default of omitting it for the CA.
  12. Points to you if you already know that you will now see the EKUE options for the CA’s users. No screenshot because it is the same EKUE window as for a self-signed certificate, other than the title. The defaults are the usual Apple S/MIME defaults of including the EKUE, marking the extension as critical, and assigning (limiting) “Email Protection” capabilities to the certificate.

    You may leave it at its defaults or disable the EKUE entirely, as you wish. As of this writing, i find no particular benefit to either option (tested only between various Macs running various OS X and Mail versions).

  13. The Basic Constraints extension for your CA is absolutely essential! You should not touch its default settings (enabled, “Use this certificate as a certificate authority”).

    The Path Length Constraint Present setting exists to place a limit on the number of certificates which may be in a certificate chain and still be considered legitimate. It is beyond the scope of this article. Its default (omitted) allows certificate chains of any length.
  14. Once again you will now see the same thing for your users: the user option for the Basic Constraints extension. As discussed in the sections on individual self-signed certificates, the Apple default is to omit the Basic Constraints extension for end-user certificates, and i’ve found that doing so works well. Again, no screenshot because it looks the same other than being disabled by default and the title indicating that it is for the end user, not the CA itself.
  15. The Subject Alternate Name Extension (SANE) for this CA is disabled by default (and for that reason, no screenshot here). I recommend leaving it this way and moving on.
  16. The SANE for the users of the CA presents an interesting conundrum: is the Apple Certificate Assistant template smart enough to drop in the correct email address for each end user as their new certificate is created by this CA? Answer: Yes, it is… at least in my testing (single email address per user), for Certificate Assistant 2.0 (Leopard 10.5) and newer (but not Certificate Assistant 1.0 for 10.4 Tiger).
  17. Now you’ll need to specify a location for the CA certificate (and keys). The default is the OS X user login keychain, and so far in my testing that appears to be the correct location.

    Might as well select the checkbox for “On this machine, trust certificates signed by this CA”, where it is available (All OS X and Certificate Assistant versions except Tiger and its Cert. Asst. 1.0).
  18. One OSes with the checkbox, we just made a change to System Certificate Trust Settings, so we’ll see the dialog:
    “You are making changes to the System Certificate Trust Settings. Type an administrator’s name and password to allow this.”
    The exact wording and appearance of this dialog window differ across OS X versions, but the general idea is as shown above for Mountain Lion.
  19. Tiger Only presents a window for the user to diddle with the configuration file name.
    “Make this CA the default” checkbox is in this window on Tiger.
  20. Finally, we’re done: the Conclusion window appears:

    Besides letting you know you’ve been successful creating your CA, this window has several buttons (4 for all OSes except Tiger) plus a “Learn More” button with helpful additional information.

    There is a button to Show Certificate Authority, which opens up the Finder window with the CA settings file and certificate. This window is the same for Certificate Assistant 2.0 for Leopard through Cert. Asst. 5.0 for Mountain Lion and newer to date (example just below. Tiger has a more primitive version of the same idea, also discussed below). On all versions except Tiger, if a website was set up for the CA, the Visit CA Web Site… button will be enabled. Also on non-Tiger versions, there’s a Show CA Certificate… button, which shows the content of the new CA certificate. Finally, and potentially most usefully, there is a button to Mail Invitation… (says “Mail Configuration File…” on Tiger Certificate Assistant version 1.0). This option will be discussed further in the section CA-Initiated Email, below, and in the next item.

  21. Before closing the Conclusion window or quitting Certificate Assistant, you may want to click the Mail Invitation… button, since there’s no good easy way to get back to this point once the CA creation process is finished, to obtain Apple’s (mostly) nicely-worded text. What happens next depends whether or not you previously set up the CA’s email address (the one you just typed into this new CA certificate).
    • If the CA’s email address on the certificate is already properly entered into Mail, you may see (depending on your OS version) the padlock (unlocked, because you have no existing S/MIME certificate for the user you’re inviting, else why would you be creating one as a CA?) and starburst seal (checked) icons in the Mail invitation message form. (If you have more than one email address set up in Mail, be certain you’ve selected the CA’s email address as the From: address.) If this is what you see and you have all the recipient email addresses ready to go for people for whom you’ll be making certificates (at least right now), go ahead and enter their information into the To: and/or CC: lines and send out this invitation message.
    • If you do not see the security icons or do not have the recipient addresses available or for any other reason are not ready to send out invitations, Save the message as a Draft—don’t send it just yet! (You don’t even need to enter recipient email addresses at this time.) I’ll explain below.

Certificate Assistant successfully creates (except on Tiger) both the settings configuration file and the .pem (Privacy Enhanced Mail) certificate file in the default location:

~/Library/Application Support/Certificate Authority/[folder: name of CA]

which, for the Finder screenshots below, is literally:

~/Library/Application Support/Certificate Authority/Monte the Mountain Lion CA
Finder icon view in newer OSes like Mountain Lion shows a certificate icon for the CA certificate. Older OSes show a blank generic icon. The configuration file always has a blank generic icon. Both icons in Finder list view are blank generic in all OS X versions to date.

Tiger (in my testing) creates the following:

~/Library/Application Support/Certificate Authority

successfully puts the settings configuration file in that folder, but fails on its promise to put any sort of CA certificate into this folder. See Version Quirks below for additional information.


Trusting the CA Certificate on the CA’s System

On OS 10.5 and newer, assuming you checked the “On this machine, trust certificates signed by this CA” when setting up the CA, you should be all set. Verify this by opening up the CA’s certificate (in Keychain Access) and checking the trust settings. Apple’s default is to Always Trust for every possible option. If yours is not set this way, make this change now (or if you have specific needs/goals, make changes as you require). If you neglected to check that box during setup, you will definitely need to make this change manually before continuing.

Due to severe bugs, Tiger users will need to do the dance of putting a copy of the CA root certificate in the X509Anchors keychain, using the same method as for self-signed certificates on that OS. The Trust settings override options in Tiger are virtually nonfunctional in my experience.

I am finding some severe bugs in the keychain infrastructure on the newer OSes (confirmed in Mountain Lion) whereby failing to select On this machine, trust certificates signed by this CA during CA setup may lead to a situation where the CA root certificate will not function properly. I have yet to find a workaround for this bug, which unfortunately blocks certificates from working on the system(s) where it happens.

If you have multiple Macs and you use these other Macs for CA work and/or use that same email address for everyday secure email and/or you will be corresponding with other people for whom your CA issues certificates on these other machines, you’ll want to move a copy of your CA credentials (or at least the certificate) over to these other systems and trust the certificate on them. Check out the section “Other Machines?” on the self-signed certificates page for your particular OS X version for details. The same information applies as for self-signed certificates + their matching keys.


Preserve your CA Credentials—Back Up!

If a self-signed certificate user fails to adequately back up their credentials (certificate and private key at least, though also saving the public key is advised), they’re only screwing themselves over. A Certificate Authority is screwing over not only themselves but also all their users. Don’t… use a sane, reliable, redundant backup arrangement. If you’re not up to it, you might want to re-think acting as a CA.

It is up to each end user to back up their own credentials, though you should back up the piece you have on your CA system (other than Tiger): each of their signed-by-you certificates. They’ll still be screwed if they lose their private key (and their correspondents are using encryption on messages sent to them), but since that key is normally not on the CA’s system, it isn’t strictly your problem. Use your discretion for family/small business situations where you may want to take on the additional responsibility of backing up your users’ private keys, and be sure that if you do this you do so very securely!

The mechanics are identical to what is needed for self-signed certificates. Please refer to the Back Up! section of the main article.


Use your Certificate Authority to Create a User Certificate for Yourself (maybe)

It is possible to create one certificate which can be utilized as both a CA and end-user certificate. I have read in the past (and didn’t save the sources so can’t cite them here) that it is unwise to have one certificate do both: it is better to keep the CA and end-user functions separated, in separate certificates. My vague recollection is that this prevents cross-contamination, such as the CA certificate going down in flames (and taking with it all certificates it has ever signed as well as itself) if it somehow becomes compromised, possibly related to its secure email or other functions. There may also be an argument regarding granularity of certificate ability permissions. In any case, for the purposes of this section i’m assuming there exist one or more good reasons to separate the functions.

Of course, if you’ve previously created your own self-signed certificate you may continue to use that. However if you’re just getting started with secure email and hoping to have many people participate with you making certificates for most or all of them, it will be easier on everyone to have your own S/MIME secure email user certificate be either your CA root certificate or a “leaf” (derivative, subordinate) certificate of your Certificate Authority.

Please note that i’m distinguishing a user’s CA function from their personal daily use of secure email. I’ve learned over the course of testing that letting the CA have a full set of secure email credentials in its own root certificate makes the process easier for setting up other users of the CA. If that is all that this particular user identity does, there may be no need to make one’s own secure email user certificate. Or, if the person acting as CA is using only one email address for being CA and in their everyday life, adding another certificate for the same email address is likely to only confuse OS X and its bundled software, so it is better to just use the CA root certificate for both functions. If there are different email addresses the person uses as CA and in their daily life, given the vague memory of the un-cited references i recommend creating a certificate separate from the CA certificate for non-CA secure email uses. If you fall in this latter category, read on and make a separate leaf certificate for your (distinct) daily use email address. If you fall in one of the other two categories (single email address for CA only or CA + daily use), skip this section and just use the CA root certificate you already made for both CA and everyday secure email purposes.

The procedure is mostly similar to, yet slightly different from, creating one’s own self-signed certificate. Whenever you see me type “the usual” and rather terse information below, this procedure exactly matches the self-signed procedure. You’ll be able to see full details with (usually) OS-appropriate screenshots in the Detailed Setup Information section of the main article, for your particular OS version.

  1. Open Certificate Assistant and select Create a Certificate….
  2. In the “Please specify a name…” or “Please specify some certificate information…” window where they ask for the name, be sure to select “Leaf” as the certificate (Identity) Type and “Let me override defaults”. Be sure that the name differs from the one you’re using for your CA (which ideally ought to have “CA” or “Certificate Authority” or some variant in it). (Certificate) Type will be S/MIME (if this isn’t listed here on your Certificate Assistant version, it will be in the next step)

    As nearly always is the case for end-user certificates, be certain to tick Let me override defaults.
  3. Now type in the usual certificate information: a new, unique serial number, a decently long validity period (but no longer than your parent CA certificate).
  4. The usual personal information comes next: email address, common name, etc.
  5. The Choose An Issuer window is next. For you as a CA yourself, it will default to your own CA.
  6. The usual Key Pair window is next, and as always, i accept the strong default settings.
  7. Now we have the usual Key Usage Extension (KUE) with the usual end-user doofy defaults which don’t allow the certificate to operate properly. I used to disable it, until Mail 10 for Sierra started requiring it, so do keep it enabled and do check Key Encipherment.
  8. The usual Extended Key Usage Extension (EKUE) for end-user is next (except on Tiger, which lacks this extension). I tend to leave it at its defaults: critical, Email Protection, though in self-signed testing i also tested disabling it and that worked fine as well.
  9. The usual Basic Constraints option is presented, not included by default (my recommendation and how i left it).
  10. OSes Leopard 10.5 and newer present the Subject Alternate Name Extension (SANE) included, not critical, and with the rfc822name correctly filled in (verify this!). I left it this way in my testing. Certificate Assistant 1.0 for Tiger leaves default not included, which is fine as well (for any OS version).
  11. The usual Specify Location window appears. As usual, the login keychain is the correct location for the completed certificate.
  12. Certificate Assistant creates the credentials (ID)—user certificate, public key, private key. Done!

Use your Certificate Authority to Create Certificates for Others

Method 1: CA-Initiated Email

This is a great way to go when your correspondent is too far away for easy in-person contact. Here are the detailed steps for OS 10.8.3 Mountain Lion and its Certificate Assistant version 5.0 and Mail 6.3 (in places interacting with OS 10.4.11 Tiger, Mail 2.1.3, and Certificate Assistant 1.0 acting as the CA):

  1. If you used the Mail Invitation… option in the Conclusion window when you originally set up the CA but did not send out messages at that time (for whatever reason), go back into Mail and re-open the Draft message you saved but did not send. This message announces that your CA is open and ready to create certificates, and will include the settings configuration file:
    Subject: “[name of CA] Certificate Authority is now available”. Message body: “The “[name of CA]” Certificate Authority is now available to accept certificate requests from you. Click the attachment and the Certificate Assistant will guide you through this process.” [name of CA].certAuthorityConfig file attached
    Note that the text is in error: it says “Click the attachment” when in fact the recipient needs to double-click the attachment to open it. This same mis-statement reappears throughout this process in the various email messages sent out by Certificate Assistant. You may wish to edit “Click” to “Double-click” before sending.
  2. Also before sending, i very much recommend signing your outgoing email invitation message with your CA’s root certificate. This will provide your root certificate to your correspondent(s), which they will need to have in place on their system for their own certificate to operate.

One might think that if the Conclusion window is already closed and no draft email was saved that it would make sense to re-open Certificate Assistant, and select Create a Certificate for Someone Else as a Certificate Authority…. The problem with doing so is that Certificate Assistant asks for an existing CSR from the end user rather than once again making the offer to email a settings file to the end user.

Instead, manually create an email message to your correspondent(s), sign it with your CA certificate, and be sure to attach the configuration file (file suffix .certAuthorityConfig) inside the folder with the name of your CA (full path is at the end of the section above).

If you’d like to use Apple’s invitation message text but didn’t save a draft, here it is (corrected to say “double-click”). Be sure to fill in your actual CA’s name in place of [the placeholder text box, like this]:

The “[name of CA goes here]” Certificate Authority is now available to accept certificate requests from you. Double click the attachment and the Certificate Assistant will guide you through this process.
  1. When your correspondent receives your invitation, your self-signed certificate will be new to them and not trusted on their system (unless you’ve used it to correspond with them in email previously and they trusted it at that time). They will need to follow the instructions for their particular OS for trusting a self-signed certificate, with the important difference that they need to set everything to Always Trust via making that selection in the top-most “When using this certificate:” pop-up list at the top of the certificate’s Trust section. This is in case your CA creates user certificates for them with additional functions beyond S/MIME email.
  2. Once your invitation shows as trusted on your correspondent’s system, they will open the attached configuration file, which will launch their Certificate Assistant. They will fill out the necessary information for their Certificate Assistant to generate a public and private key pair (automatically installed into their default [usually: login] keychain) and complete their CSR:
  3. Their Cert. Asst. will create a CSR with their public key, put up a Conclusion window with explanatory text, and create an outgoing email message with the CSR attached for them to email back to you (the CA). Here is what the outbound message with attached CSR looks like in Mail 6 for Mountain Lion:

    The user sees the Certificate Assistant Conclusion window, with instructions about what they’ll do next.
  4. You (the CA) will open the CSR in the email you receive from your correspondent, which re-launches your Certificate Assistant to generate their finished authenticated certificate. The attachment is:

    CertificateSigningRequest.certSigningRequest

    The CA sees the Issuing Certificate Authority window:

    With all OS versions so far except 10.4 Tiger, using the defaults will use the information from the CA’s configuration file: Certificate Assistant successfully respected my CA’s choices for omitting KUE and including the SANE, properly filled in. Certificate Assistant also successfully increments the serial number to the next non-conflicting value when using defaults, in my tests.

    People acting as CAs need to pay careful attention: there is a bug in some versions of Certificate Assistant (confirmed on versions 2.0, 3.0, and 4.4) whereby the CA’s copy sometimes generates a new, spurious set of user keys along with a certificate in the CA’s keychain. The CA’s Certificate Assistant should only generate a new user certificate (in the CA’s keychain and in an outgoing Mail message form). If you the CA see a pair of new user keys appear in your own CA keychain on this step, please immediately detour to User Certificate Fails to Work and/or CA Certificate Assistant Generates Spurious User Keys.

  5. Cert. Asst. 2.0 and newer uses Mail to pre-fill an outgoing message with the completed user certificate in a certificate.pem file. A copy of this user cert. is also placed into the CA’s login keychain (and shows as valid since the CA’s credentials are already there and trusted).
    Note: the CA may be given the option to encrypt (padlock icon) the outgoing email message to the user, containing the user’s new signed certificate. DON’T: the end user does not have their certificate yet, which is in this very email message and not yet installed! Leave the padlock unlocked for this message!
    This completes the process at the CA end.
  6. Your correspondent will receive one final email with their completed, authenticated certificate, ready to be double-clicked:

    It will be installed into their login keychain, next to their keys which were generated earlier in the process on their own system, for a complete credential set. (The screenshot shows a Tiger-created certificate in .p7b format. Leopard 10.5 and newer will supply the final user certificate in .pem format. Either one should work properly.) The process is now complete at both ends.

Note that in this process, the user’s (remote correspondent’s) private key is generated on their own system via their own Certificate Assistant utility program, using the CA’s configuration file initially emailed. Their private key never leaves their system and remains secure. Clever!

Done Yet?

Maybe Yes

If the CA followed the instructions carefully and everything went well, the CA’s certificate should have been provided to the user via the initial email invitation, when that message was sent out signed with the CA’s self-signed root certificate. Or, if not on the initial message, perhaps the one conveying the newly-signed certificate. Assuming this happened and the user trusted the incoming CA certificate on their system, the process is now complete at both ends. Remember that it will be necessary to Quit Mail (all OS X versions to date) and restart it before secure email options appear.

Maybe No

If the CA failed to send out a properly signed invitation, or if the recipient user had reasons not to trust the certificate (maybe they were not expecting the invitation, which could come from anyone) or had trouble trusting it, the user will have to obtain the CA’s root certificate (if they don’t already have it) and trust it on their system. Because the CA certificate is not yet in the user’s system or is not yet trusted, they will see a warning on their own certificate regarding its being signed by an unknown CA:


Leopard screenshot

Apple’s original intent (judging from Help file content and other explanatory text) appears to have been that the CA would make its certificate available on a secure server of some kind. Seems to me that the main issue with sending a CA certificate via email is knowing whether it actually came from the CA, and whether or not a “man-in-the-middle” may have modified it. This same situation arises with individual self-signed certificates and i propose the same solution:

  1. The CA and user set up a time they can work together.
  2. The CA emails their certificate to the user, via signing a message to them with this certificate (skip this step if they already have it but have not trusted it). If you attempt to attach the certificate manually instead of simply signing the outgoing message, you are on your own. That isn’t Apple’s design intent and i have done absolutely no testing of this. Signed certificates automatically go into the user’s keychain; attached certificates probably will not.
  3. The CA and user communicate via some other channel, such as a voice telephone call or video chat, where they both can have high confidence that the other person is who they claim to be.
  4. The user imports the CA certificate into their keychain (if it is not already there). The specific keychain into which to place the CA certificate varies with OS version and whether the CA certificate will apply to this OS X user account only, or machine-wide. See Version Quirks for specifics for your OS version.
  5. The CA reads off one of the two digital fingerprints for their certificate, the user confirming that what the CA is reading matches what they are seeing on their copy of the CA’s certificate’s fingerprint.

This verification procedure is discussed further in the main article section ID Verification. (The main article discusses two-way verification. It is only necessary to one-way verify the CA certificate for the setup procedure we’re describing here.)

The final step is the user manually trusting the CA’s certificate on their system. Follow the steps for your particular OS version, same as for a self-signed certificate, other than CA root certificates are normally trusted for all abilities, in case the CA issues a user certificate for other/additional functions.


Method 2: Correspondent (end user)-Initiated Certificate Signing Request (CSR) Email

It is not necessary for an end user to receive an invitation from a CA with a settings file as the first step. It is entirely possible for the end user to use their copy of Certificate Assistant to create a key pair for themself, generate a CSR, and send it to the CA (if they have the CA’s email address) or via some other means (if they don’t have the CA’s email address). We’ll cover each of these cases, starting with the first.

  1. User picks Request a Certificate From a Certificate Authority… in their copy of Certificate Assistant.
  2. The usual User CSR information window appears:

    The default of “Request is: Emailed to the CA” is what we’re discussing in this section. The user is given the option to override the default key pair information. Since the default on all versions of Certificate Assistant is the strongest RSA key pair Certificate Assistant can make (same as for the CA itself), i did not experiment with this override in my testing, other than to see that it brings up the very same Key Pair window as appears when creating a CA and creating a self-signed certificate. Unless the CA is insane and goes with a less secure key pair, there really is no point to using this. If the user chooses to do so anyway, the CA can look at the final cert. before sending it out to verify its settings, and refuse to email the finished cert. back to the user who sent in the CSR, if the CA disagrees with the user’s key override choices.
  3. The usual Conclusion window is next. Depending upon the Certificate Assistant version, Cert. Asst. will either direct-email the CSR to the CA itself, or invoke Mail with a pre-filled outgoing message to the CA for the user to send manually. Public and Private keys for the user are already generated and placed into the default (almost always: login) keychain.
  4. The CA opens the received CSR. The Issuing Certificate Authority window opens in their copy of Certificate Assistant. This is one case where i found that Certificate Assistant did the correct thing with the defaults. You can always try the defaults then inspect the certificate carefully before emailing it back to the user. If it is faulty, delete the outgoing email message draft, delete the new user certificate from your keychain, and run the CSR again, overriding defaults. The CA’s Certificate Assistant will email the completed, signed certificate to the user who submitted the CSR, to the email address on the certificate. Be sure to sign the outgoing messages with the CA’s certificate! (for Certificate Assistant versions which use Mail to send rather than direct-sending themselves).
  5. If the CA’s root certificate is not already properly installed in the user’s system, this will need to be done before the user’s newly signed certificate can be used. The user will know because the CA’s signature will show as “Unable to verify message signature” in the incoming message containing the signed certificate, if it is not currently trusted. The user needs to trust the CA’s certificate using the usual methods.
  6. The user will double-click the attached certificate (.pem) and put it into their default (login) keychain.
  7. User quits and re-launches Mail: secure email is available.

Method 3: Correspondent (end user)-Initiated Certificate Signing Request (CSR) (non-email)

It may be the case that an end user knows of a Certificate Authority (CA) but does not have their email address or for some reason wishes not to use email to convey the CSR to the CA (or as in one of my testing cases, Certificate Assistant may fail on the emailing out step, requiring a workaround). All versions of Certificate Assistant provide for this scenario as well. The procedure in this case is very close to that described above, for email submission of the CSR to the CA.

  1. User picks Request a Certificate From a Certificate Authority… in their copy of Certificate Assistant.
  2. The usual User CSR information window appears:

    The default is “Request is: Emailed to the CA”, but there is also an option “Request is: Saved to disk”, which is what we’re discussing in this section. There is no need to fill in the CA Email Address, though as always the User Email Address is mandatory. The user is given the option to override the default key pair information. Since the default on all versions of Certificate Assistant is the strongest RSA key pair Certificate Assistant can make (same as for the CA itself), i did not experiment with this override in my testing, other than to see that it brings up the very same Key Pair window as appears when creating a CA and creating a self-signed certificate. Unless the CA is insane and goes with a less secure key pair, there really is no point to using this. If the user chooses to do so anyway, the CA can look at the final cert. before sending it out to verify its settings, and refuse to email the finished cert. back to the user who sent in the CSR, if the CA disagrees with the user’s key override choices.
  3. The usual OS Save As… window appears, allowing the user to select where to save their CSR. This might be a flash drive or some other removable mass storage medium if the user intends to personally deliver the CSR to the CA. (I simply put the file on the desktop and used home network file sharing for my testing.)
  4. The usual Conclusion window is next, with a handy Show In Finder… button in case the user was not careful picking a location in the Save As… window, or for whatever reason cannot locate the new CSR file. Public and Private keys for the user are already generated and placed into the default (almost always: login) keychain. Now the user gets the CSR file to the CA via whatever means they choose.
  5. The CA opens the received CSR. The Issuing Certificate Authority window opens in their copy of Certificate Assistant. This is one case where i found that Certificate Assistant did the correct thing with the defaults. You can always try the defaults then inspect the certificate carefully before emailing or otherwise getting it back to the user. Even though the CSR was delivered via a mechanism other than email, the CA’s Certificate Assistant will email the completed, signed certificate to the user who submitted the CSR, to the email address on the certificate. For Certificate Assistant 2.0 or later (OS 10.5 Leopard and later), this is done via Mail, so it is possible to cancel the outgoing email message before it is sent, if for some reason a non-email method of delivering the completed signed certificate to the user is desired. I’ve seen later versions (2.0+) of Certificate Assistant default to .pem format for certificates, so that’s the format i’d tend to choose for certificate export, lacking other information/concerns. Distribution to the user via secure file server, physical media exchange, or other method are all options. If the CA is not returning a signed email message and is instead using some other form of file transfer, they need to include their CA root certificate in the package in addition to the user’s new signed certificate.
  6. Once the user obtains the signed certificate package from the CA, they will first need to install and/or trust the CA’s root certificate if it is not already properly installed in the user’s system. This will need to be done before the user’s newly signed certificate can be used. The user needs to trust the CA’s certificate using the usual methods.
  7. With the CA’s certificate installed and trusted, the user will double-click their own (new) certificate and put it into their default (login) keychain.
  8. User quits and re-launches Mail: secure email is available.

Make Them Back Up!

Whichever method is used to generate end-user correspondents’ security credentials, they have the same need as you to ensure that they don’t lose them. Especially their private key, without which they cannot decrypt and read existing encrypted email messages sent to them!

Unless you have secure remote access to their system (in which case this whole credential-making procedure could be handled many different ways), you’ll need to count on them to follow the same steps as users of self-signed credentials do, discussed in the main article, to back them up. Or, make that long-overdue in-person visit and fix that garage light while you’re there!


Interoperation

I successfully tested the full process from CA invitation through installation and testing of a new user CA-signed certificate between each version of OS X from 10.4.11 Tiger through 10.8.3 Mountain Lion, in both directions (in other words: with each OS taking a turn as both CA and end user)—all 20 combinations. In all cases the process worked correctly.

Given the changes in security credential handling in Mail 10 for macOS 10.12 Sierra, i retested between it (as the CA) and OS 10.4.11 Tiger. Again, the process worked correctly. Presumably this “longest reach” test covers the intermediate OS and bundled software versions too.


Problems?

User’s Certificate Assistant Fails to Work with CA’s Configuration File

First observation

I saw one case where Certificate Assistant 1.0 for Tiger could not open a Certificate Assistant 5.0 settings file. Yet when i tested this combination later, it worked fine. I did not thoroughly re-test (i need to get back to the rest of my life), but my suspicion is that the configuration file which could not be opened may have been due to that file being signed by the CA using the handy checkbox during CA setup.

Now, my understanding is imperfect. I thought that the checkbox during CA setup would not affect the configuration file itself, but only what happens in Mail such that the outgoing message is signed or not signed. I’ve seen a couple of configuration files with “garbage” in them before and after the properly formatted Property List content. I do not know whether this is intentional or a bug.

In my testing, if the configuration file from the CA is a clean Property List file with nothing preceding nor following the <?xml…>… </plist> content, it should work correctly.

Second observation

Testing between Certificate Asssistant 5.0 on OS 10.11.6 El Capitan between two different user accounts on the same Mac. I created a CA in a user account which already had a working self-signed certificate for email. The CA’s certificate did have a different serial number, but the same email address. Going against my own advice, i sent out an invitation straight out of Certificate Assistant. When the other OS X user attempted to run the configuration file, they got:

alt="An Error Occurred. The file you specified could not be opened by this assistant."

I spent about 20 minutes trying to find a workaround, coming up with nothing other than the same thing which i figured out years earlier during the first observation: ignore what the CA sends and have the non-CA user send the CA a CSR (see below). To avoid this issue, i strongly recommend:

If the CA’s configuration file simply won’t work, have the user ignore it and use the Request a Certificate From a Certificate Authority… command in their version of Certificate Assistant. I’ve not yet seen that fail to work.

Can’t create certificate/place in keychain

Certificate serial numbers matter for your own CA-generated certificates—all of them, including the root CA certificate! Track them and do not duplicate them in any certificates issued by your CA. Failure to mind this point is likely to lead to failure of Certificate Assistant to successfully create or install some certificates. See the note near the page top for more.

User Certificate Fails to Work and/or CA Certificate Assistant Generates Spurious User Keys

There is a bizarre show-stopping bug with some versions of Certificate Assistant (2.0 for OS 10.5 Leopard, 3.0 for OS 10.6 Snow Leopard, 4.4 for OS 10.7 Lion, 5.0 for OS 10.11 El Capitan have all been confirmed): Usually only on the first run with a newly set up CA (esp. for Snow Leopard) when the CA runs the user’s CSR, the CA’s Certificate Assistant generates a spurious new pair of user keys on the CA’s system along with a certificate to match those keys—not the keys already (securely) generated on the user’s system by their Certificate Assistant. Sometimes Certificate Assistant presents an error message that the new user’s certificate cannot be placed into the keychain as it is a duplicate!

Fortunately, there is a workaround:

  1. Delete the spurious user keys and user certificate from the CA’s default (usually: login) keychain. Note that in some cases there will not be a user certificate, if Certificate Assistant presented the duplicate certificate in keychain error. Be sure to check carefully!
  2. If Certificate Assistant made it far enough to create the outgoing email message with the defective certificate, delete this message draft.
  3. Re-run the CSR your user sent in, as if you were doing so for the first time.

This is a very difficult bug to reproduce! In my Snow Leopard testing, once Certificate Assistant for the CA starts working correctly, it continues to do so unless the whole OS X installation is blown away and installed fresh, or at least all user accounts on the Mac and existing CA-related email messages (on the email server[s]) are blown away AND caches are wiped out. Then on another day the first certificate of the session failed in this way even though it was an existing installation which had previously been working (but the workaround still worked). On 10.5 Leopard it happened with the second CSRequest. 10.7.5 Lion did this to me once under circumstances not in any way noticeably different than the other 3 times i did the (probably not literally) exact same thing with the very same CA installation with no problems whatsoever. Because of the difficulty testing it, i cannot guarantee that it is gone in newer OS X versions.

The good news is that, up through Yosemite, whenever this bug occurs, no matter what OS X version, the workaround described above (trashing the bogus cert. and keys and re-running the very same CSR a second time) has succeeded.

El Capitan Summer 2016 Update

Not sure whether it’s chance or something related to OS 10.11 El Capitan, but i’ve found a reproducible case where the failure keeps going, even after trashing the spurious keys and certificates. What i’m finding so far is that a corrupted CA.certAuthorityConfig file triggers this bug, and likely other ones. To avoid problems, ensure that your CA’s config file is OK before issuing certificates.

Check your CA.certAuthorityConfig file for corruption
You may use BBEdit, TextEdit, or any other app which will show you the raw text of the file.

Note that i forced a few line wraps in the corrupted example above, to prevent this page from trying to display too wide. The original is even messier! For presentation here, all kinds of control characters have been replaced with spaces. As well, email@domain.com is a placeholder for a legitimate (uncorrupted within itself) email address i do not wish to share here.

Anyone internal to Apple who may be reading this might consider checking out my bug on this issue, Radar #13665874.

User Certificate Generated by CA Fails to Work on CA’s Own System

I encountered at least one case with Mountain Lion 10.8.3, Certificate Assistant 5.0, Keychain Access 7.0, and Mail 6.3 whereby Mail refused to acknowledge the brand-new user certificate right there in the CA’s account, even though Keychain Access showed everything was just fine and dandy and i’d quit and restarted Mail several times (to refresh its outlook on certificates—the only way i know). Interestingly, Certificate Assistant’s “Evaluate a Certificate” function claimed there was no root certificate found for the new user certificate:

Evaluation Status: No root cert found

I stumbled into a workaround by accident: When i added the CA self-signed root certificate to the list of certificates to be evaluated in Certificate Assistant, BOINK!—everything started working. Certificate Assistant now showed “Evaluation Status: Success” and Mail now happily accepted the new user certificate (after a fresh start of Mail).

Unfortunately, another time this happened (and i don’t recall which OS), Certificate Assistant temporarily showed that everything was fine when both the root and user certificates remained in its evaluation window, but after any sort of logout or restart or maybe even quitting Certificate Assistant, the failure returned.

I have not found a workaround/fix. This problem occurred when i failed to select “On this machine, trust certificates signed by this CA”, and attempted to trust later in the standard OS X user account, apparently triggering this failure.

PhoneGap Build iOS error: “Certificate doesn’t match profile: The default keychain doesn’t have an identity matching”

Kindly submitted by Marcellus S.

The author of this site had no idea what PhoneGap Build even was until i looked it up. Between that and having never touched Apple’s Developer Console, i believe the safest course of action is for me to quote relevant parts of his submission in its entirety:

For the past 10 hours, I’ve been struggling with PhoneGap Build’s iOS error “Certificate doesn’t match profile: The default keychain doesn’t have an identity matching”, but I have a solution!

My Mac’s OS is version 10.8.5, and my KeyChain is version 7. After following the instructions in the Be Your Own Certificate Authority article [this one —Sonic], I opened Apple’s Developer Console. I used Apple’s Console to create a Certificate and a Provisioning Profile. Finally, I created a p12 file using the Certificate I created following the instructions in the Be Your Own Certificate Authority article; please note, this final process was not a part of the instructions – but a process I picked up in the past from working on previous iOS apps.

The solution is to create your p12 file by using KeyChain to export the Certificate created by Apple’s Developer Console. KeyChain version 7 will display Apple’s Certificate with a warning/error message, stating “This certificate was signed by an unknown authority”. This can be ignored.

If you’re like me, when you saw this warning/error message, you used unnecessary caution, and created your p12 file by using KeyChain to export the Certificate created in the Be Your Own Certificate Authority article. Again, the caution is unnecessary.

As I had mentioned before, ignore the warning/error message “This certificate was signed by an unknown authority”. Create your p12 file using the Certificate you created in Apple’s Developer Console. PhoneGap Build will accept the p12 and Provisioning Profile created from the Developer Console Certificate. That’s it! I will be posting a much briefer version of this solution on PhoneGap Build’s forum only, since this situation originates in PhoneGap Build.


Version Quirks

Certificate Assistant 1.0, OS 10.4.11 Tiger, Mail 2.1.3

Certificate Assistant 2.0, OS 10.5.8 Leopard, Mail 3.6

Certificate Assistant 3.0, OS 10.6.8 Snow Leopard, Mail 4.5

Certificate Assistant 4.4, OS 10.7.5 Lion, Mail 5.3

Certificate Assistant 5.0, OS 10.8.3 Mountain Lion, Mail 6.3

Certificate Assistant 5.0, OS 10.9.5 Mavericks, Mail 7.3

Certificate Assistant 5.0, OS 10.10.5 Yosemite, Mail 8.2 and Certificate Assistant 5.0, OS 10.11.6 El Capitan, Mail 9.3

Not Using Mail?

I have to wonder what happens when a Mac user has their OS X set up to use a Mail User Agent (MUA, a.k.a. email client software) other than Apple’s Mail (e.g. Thunderbird, Eudora, Lookout! Excess [Outlook Express] etc. etc.): will their Certificate Assistant successfully create outbound email messages in the alternate program? I’d hope so, but i’m not curious enough to actually set up this scenario and test it (i like Mail). Be wary of this point if you’re not using Mail.


[1] To be precise, the X509Anchors keychain no longer exists in the user interface, due to being deprecated. I saw one still present in /System/Library/Keychains on 10.8.3 Mountain Lion. This series of articles is only concerned with the user experience and the GUI.


Secure Email in OS X, Apple Mail Sonic’s signatureThe Sonically Pure Pages

This Siber-Sonically Pure Page is Valid CSS! and Valid HTML 4.01! Transitional compliant.