"certtool" Command for Certificates on macOS

This section provides a tutorial example on how to use the 'certtool' command to manage certificates on macOS computers.

macOS also offers another command line interface called "certtool" for you to manage certificate files. Here are some examples on how to use the "certtool" command.

Create a self-signed certificate - It will be stored in a given keychain.

herong$ certtool c k=MyChain
  Enter key and certificate label: MyRoot
  
  Select key algorithm by letter: e
  Enter key size in bits or CR for default: 256
  You have selected algorithm ECDSA, key size 256 bits.
    OK (y/anything)? y

  Enter cert/key usage (s=signing, b=signing AND encrypting, ...: b
  ...Generating key pair...

  Select signature algorithm by letter: 2
  You have selected algorithm ECDSA with SHA256.
    OK (y/anything)? y

  ...creating certificate...
  ..cert stored in Keychain.

List all certificates in a given keychain

herong$ certtool y k=MyChain 

Serial Number      : 41 9F 61 
Issuer Name        :
   Common Name     : MyRoot
   Country         : US
   Org             : Apple
   OrgUnit         : Engineering
   State           : California
   Email addrs     : joe@apple.com
Subject Name       :
   Common Name     : MyRoot
   Country         : US
   Org             : Apple
...
...1 certificates found
...0 CRLs found

Dump a certificate from a given keychain

herong$ security find-certificate -c MyRoot -p MyChain > MyRoot.pem

herong$ ls -l *.pem 
-rw-r--r--  1 herong  staff  733 May  4 08:37 MyRoot.pem

Display info from a given certificate file

herong$ certtool d MyRoot.pem

Serial Number      : 41 9F 61 
Issuer Name        :
   Common Name     : MyRoot
   Country         : US
   Org             : Apple
   OrgUnit         : Engineering
   State           : California
   Email addrs     : joe@apple.com
Subject Name       :
   Common Name     : MyRoot
   Country         : US
   Org             : Apple
...

Table of Contents

 About This Book

 Introduction of PKI (Public Key Infrastructure)

 Introduction of HTTPS (Hypertext Transfer Protocol Secure)

 Using HTTPS with Google Chrome

 Using HTTPS with Mozilla Firefox

 Using HTTPS with Microsoft Edge

 Using HTTPS with Apple Safari

 Using HTTPS with IE (Internet Explorer)

 Android and Server Certificate

 iPhone and Server Certificate

 Windows Certificate Stores and Console

 RDP (Remote Desktop Protocol) and Server Certificate

macOS Certificate Stores and Keychain Access

 What Is Keychain Access on macOS

 Listing of Trusted Root CA in macOS

 Exporting Root Certificate to File from macOS

 Delete/Untrust Certificates from macOS

 Unlock Keychain to Access Certificate on macOS

 Import Server Certificates to macOS

 Create My Own Root CA on macOS

 Review My Root CA Certificate on macOS

 Review Private Key of My CA Certificate on macOS

 Generate CSR (Certificate Signing Request) on macOS

 Issue New Certificate with My CA on macOS

 Verify Certificate Signed by My CA on macOS

 "security" Command for Keychains on macOS

"certtool" Command for Certificates on macOS

 Keychain File Locations on macOS

 CA Certificates at "/etc/ssl | /private/etc/ssl"

 Linux Certificate Stores and Tools

 Perl Scripts Communicating with HTTPS Servers

 PHP Scripts Communicating with HTTPS Servers

 Python Scripts Communicating with HTTPS Servers

 Java Programs Communicating with HTTPS Servers

 .NET Programs Communicating with HTTPS Servers

 CAcert.org - Root CA Offering Free Certificates

 PKI CA Administration - Issuing Certificates

 Comodo Free Personal Certificate

 Digital Signature - Microsoft Word

 Digital Signature - OpenOffice.org 3

 S/MIME and Email Security

 PKI (Public Key Infrastructure) Terminology

 Archived Tutorials

 References

 Full Version in PDF/EPUB