How to import X.509 certificates into MacOS? I have the file with X.509 certificates and the following preamble:

# This is a bundle of X.509 certificates of public Certificate
# Authorities.  It was generated from the Mozilla root CA list.
# These certificates are in the OpenSSL "TRUSTED CERTIFICATE"
# format and have trust bits set accordingly.
# An exception are auxiliary certificates, without positive or negative
# trust, but are used to assist in finding a preferred trust path.
# Those neutral certificates use the plain BEGIN CERTIFICATE format.


I tried to import it from command line but it fails:

$ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /Users/dzieciou/projects/mg/etc/pki/tls/certs/megabundle.crt

readFile: short read
***Error reading file /Users/dzieciou/projects/mg/etc/pki/tls/certs/
Error reading file /Users/dzieciou/projects/mg/etc/pki/tls/certs/megabundle.crt


I was able to import those certificates into Firefox on MacOS but Firefox does not use the system keychain.
Keychain Access

You can import a wide range of certificate formats with macOS's Keychain application.


Open Applications > Utilities > Keychain Access.app
Select the menu item: File > Import Items…


Default Keychain

The imported items will appear in the current default keychain. If this is not what you want, be sure to change the default before importing.