MallocStackLogging
When using the leaks command or the -l option it's probably a good idea to set this environment variable before security is started. Doing so will allow leaks to display symbolic backtraces.
Command line interface to keychains and security framework
security [-hilqv]
[-p
prompt]
[command]
[command_options]
[command_args]
A simple command line interface which lets you administer keychains, manipulate keys and certificates, and do just about anything the Security framework is capable of from the command line.
By default security will execute the command supplied and report if anything went wrong.
If the -i or -p options are provided, security will enter interactive mode and allow the user to enter multiple commands on stdin. When EOF is read from stdin security will exit.
Here is a complete list of the options available:
-h
If no arguments are specified, show a list of all commands. If arguments are provided, show usage for each the specified commands. This option is essentially the same as the help command.
-i
Run security in interactive mode. A prompt ( security> by default) will be displayed and the user will be able to type commands on stdin until an EOF is encountered.
-l
Before security exits, run
/usr/bin/leaks -nocontext
on itself to see if the command(s) you executed had any leaks.
-p prompt
This option implies the -i option but changes the default prompt to the argument specified instead.
-q
Will make security less verbose.
-v
Will make security more verbose.
security provides a rich variety of commands (command in theSYNOPSIS) , each of which often has a wealth of options, to allow access to the broad functionality provided by the Security framework. However, you don't have to master every detail for security to be useful to you.
Here are brief descriptions of all the security commands:
helpShow all commands, or show usage for a command.
list-keychainsDisplay or manipulate the keychain search list.
default-keychainDisplay or set the default keychain.
login-keychainDisplay or set the login keychain.
create-keychainCreate keychains.
delete-keychainDelete keychains and remove them from the search list.
lock-keychainLock the specified keychain.
unlock-keychainUnlock the specified keychain.
set-keychain-settingsSet settings for a keychain.
set-keychain-passwordSet password for a keychain.
show-keychain-infoShow the settings for keychain.
dump-keychainDump the contents of one or more keychains.
create-keypairCreate an asymmetric key pair.
add-generic-passwordAdd a generic password item.
add-internet-passwordAdd an internet password item.
add-certificatesAdd certificates to a keychain.
find-generic-passwordFind a generic password item.
delete-generic-passwordDelete a generic password item.
set-generic-password-partition-listSet the partition list of a generic password item.
find-internet-passwordFind an internet password item.
delete-internet-passwordDelete an internet password item.
set-internet-password-partition-listSet the partition list of a internet password item.
find-keyFind keys in the keychain
set-key-partition-listSet the partition list of a key.
find-certificateFind a certificate item.
find-identityFind an identity (certificate + private key).
delete-certificateDelete a certificate from a keychain.
delete-identityDelete a certificate and its private key from a keychain.
set-identity-preferenceSet the preferred identity to use for a service.
get-identity-preferenceGet the preferred identity to use for a service.
create-dbCreate a db using the DL.
exportExport items from a keychain.
importImport items into a keychain.
cmsEncode or decode CMS messages.
install-mdsInstall (or re-install) the MDS database.
add-trusted-certAdd trusted certificate(s).
remove-trusted-certRemove trusted certificate(s).
dump-trust-settingsDisplay contents of trust settings.
user-trust-settings-enableDisplay or manipulate user-level trust settings.
trust-settings-exportExport trust settings.
trust-settings-importImport trust settings.
verify-certVerify certificate(s).
authorizePerform authorization operations.
authorizationdbMake changes to the authorization policy database.
execute-with-privilegesExecute tool with privileges.
leaksRun /usr/bin/leaks on this process.
smartcardsEnable, disable or list disabled smartcard tokens.
list-smartcardsDisplay available smartcards.
export-smartcardExport/display items from a smartcard.
errorDisplay a descriptive message for the given error code(s).
This section describes the command_options that are available across most security commands.
-h
Show a usage message for the specified command. This option is essentially the same as the help command.
Here (finally) are details on all the security commands and the options each accepts.
help
Show all commands, or show usage for a command.
list-keychains [-h] [-d user|system|common|dynamic] [-s [keychain...]]
-d user|system|common|dynamicUse the specified preference domain.
-sSet the search list to the specified keychains.
Display or manipulate the keychain search list.
default-keychain [-h] [-d user|system|common|dynamic] [-s [keychain]]
-d user|system|common|dynamicUse the specified preference domain.
-sSet the default keychain to the specified keychain. Unset it if no keychain is specified.
Display or set the default keychain.
login-keychain [-h] [-d user|system|common|dynamic] [-s [keychain]]
-d user|system|common|dynamicUse the specified preference domain.
-sSet the login keychain to the specified keychain. Unset it if no keychain is specified.
Display or set the login keychain.
create-keychain [-hP] [-p password] [keychain...]
-PPrompt the user for a password using the SecurityAgent.
-p passwordUse password as the password for the keychains being created.
If neither -P or -p password are specified, the user is prompted for a password on the command line. Use of the -p option is insecure.
Create keychains.
delete-keychain [-h] [keychain...]
Delete keychains and remove them from the search list.
lock-keychain [-h] [-a|keychain]
Lockkeychain , or the default keychain if none is specified. If the -a option is specified, all keychains are locked.
unlock-keychain [-hu] [-p password] [keychain]
Unlockkeychain , or the default keychain if none is specified.
set-keychain-settings [-hlu] [-t timeout] [keychain]
-lLock keychain when the system sleeps.
-uLock keychain after timeout interval.
-t timeoutSpecify timeout interval in seconds (omitting this option specifies "no timeout").
Set settings forkeychain , or the default keychain if none is specified.
set-keychain-password [-h] [-o oldPassword] [-p newPassword] [keychain]
-o oldPasswordOld keychain password (if not provided, will prompt)
-p newPasswordNew keychain password (if not provided, will prompt)
Set password forkeychain , or the default keychain if none is specified.
show-keychain-info [keychain]
Show the settings forkeychain .
dump-keychain [-adhir] [keychain...]
-aDump access control list of items
-dDump (decrypted) data of items
-iInteractive access control list editing mode
-rDump raw (encrypted) data of items
Dump the contents of one or more keychains.
create-keypair [-h] [-a alg] [-s size] [-f date] [-t date] [-d days] [-k keychain] [-A|-T appPath] [description]
-a algUse alg as the algorithm, can be rsa, dh, dsa or fee (default rsa)
-s sizeSpecify the keysize in bits (default 512)
-f dateMake a key valid from the specified date (ex: "13/11/10 3:30pm")
-t dateMake a key valid to the specified date
-d daysMake a key valid for the number of days specified from today
-k keychainUse the specified keychain rather than the default
-AAllow any application to access this key without warning (insecure, not recommended!)
-T appPathSpecify an application which may access this key (multiple-T options are allowed)
Create an asymmetric key pair.
add-generic-password [-h] [-a account] [-s service] [-w password] [options...] [-A|-T appPath] [keychain]
-a accountSpecify account name (required)
-c creatorSpecify item creator (optional four-character code)
-C typeSpecify item type (optional four-character code)
-D kindSpecify kind (default is "application password")
-G valueSpecify generic attribute value (optional)
-j commentSpecify comment string (optional)
-l labelSpecify label (if omitted, service name is used as default label)
-s serviceSpecify service name (required)
-p passwordSpecify password to be added (legacy option, equivalent to-w )
-w passwordSpecify password to be added. Put at end of command to be prompted (recommended)
-AAllow any application to access this item without warning (insecure, not recommended!)
-T appPathSpecify an application which may access this item (multiple-T options are allowed)
-UUpdate item if it already exists (if omitted, the item cannot already exist)
-X passwordSpecify password data to be added as a hexadecimal string
By default, the application which creates an item is trusted to access its data without warning. You can remove this default access by explicitly specifying an empty app pathname: -T "". If no keychain is specified, the password is added to the default keychain.
Add a generic password item.
add-internet-password [-h] [-a account] [-s server] [-w password] [options...] [-A|-T appPath] [keychain]
-a accountSpecify account name (required)
-c creatorSpecify item creator (optional four-character code)
-C typeSpecify item type (optional four-character code)
-d domainSpecify security domain string (optional)
-D kindSpecify kind (default is "application password")
-j commentSpecify comment string (optional)
-l labelSpecify label (if omitted, service name is used as default label)
-p pathSpecify path string (optional)
-P portSpecify port number (optional)
-r protocolSpecify protocol (optional four-character SecProtocolType, e.g. "http", "ftp ")
-s serverSpecify server name (required)
-t authenticationTypeSpecify authentication type (as a four-character SecAuthenticationType, default is "dflt")
-w passwordSpecify password to be added. Put at end of command to be prompted (recommended)
-AAllow any application to access this item without warning (insecure, not recommended!)
-T appPathSpecify an application which may access this item (multiple-T options are allowed)
-UUpdate item if it already exists (if omitted, the item cannot already exist)
-X passwordSpecify password data to be added as a hexadecimal string
By default, the application which creates an item is trusted to access its data without warning. You can remove this default access by explicitly specifying an empty app pathname: -T "". If no keychain is specified, the password is added to the default keychain.
Add an internet password item.
add-certificates [-h] [-k keychain] file...
Add certficates contained in the specified files to the default keychain. The files must contain one DER encoded X509 certificate each.
-k keychainUse keychain rather than the default keychain.
find-generic-password [-h] [-a account] [-s service] [options...] [-g] [keychain...]
-a accountMatch account string
-c creatorMatch creator (four-character code)
-C typeMatch type (four-character code)
-D kindMatch kind string
-G valueMatch value string (generic attribute)
-j commentMatch comment string
-l labelMatch label string
-s serviceMatch service string
-gDisplay the password for the item found
-wDisplay the password(only) for the item found
Find a generic password item.
delete-generic-password [-h] [-a account] [-s service] [options...] [keychain...]
-a accountMatch account string
-c creatorMatch creator (four-character code)
-C typeMatch type (four-character code)
-D kindMatch kind string
-G valueMatch value string (generic attribute)
-j commentMatch comment string
-l labelMatch label string
-s serviceMatch service string
Delete a generic password item.
delete-internet-password [-h] [-a account] [-s server] [options...] [keychain...]
-a accountMatch account string
-c creatorMatch creator (four-character code)
-C typeMatch type (four-character code)
-d securityDomainMatch securityDomain string
-D kindMatch kind string
-j commentMatch comment string
-l labelMatch label string
-p pathMatch path string
-P portMatch port number
-r protocolMatch protocol (four-character code)
-s serverMatch server string
-t authenticationTypeMatch authenticationType (four-character code)
Delete an internet password item.
find-internet-password [-h] [-a account] [-s server] [options...] [-g] [keychain...]
-a accountMatch account string
-c creatorMatch creator (four-character code)
-C typeMatch type (four-character code)
-d securityDomainMatch securityDomain string
-D kindMatch kind string
-j commentMatch comment string
-l labelMatch label string
-p pathMatch path string
-P portMatch port number
-r protocolMatch protocol (four-character code)
-s serverMatch server string
-t authenticationTypeMatch authenticationType (four-character code)
-gDisplay the password for the item found
-wDisplay the password(only) for the item found
Find an internet password item.
find-key [options...] [keychain...]
-a application-labelMatch "application label" string
-c creatorMatch creator (four-character code)
-dMatch keys that can decrypt
-D descriptionMatch "description" string
-eMatch keys that can encrypt
-j commentMatch comment string
-l labelMatch label string
-rMatch keys that can derive
-sMatch keys that can sign
-t typeType of key to find: one of "symmetric", "public", or "private"
-uMatch keys that can unwrap
-vMatch keys that can verify
-wMatch keys that can wrap
Search the keychain for keys.
set-generic-password-partition-list [-a account] [-s service] [-S partition-list] [-k password] [options...] [keychain]
-S partition-listComma-separated partition list. See output of "security dump-keychain" for examples.
-k passwordPassword for keychain (deprecated)
-a accountMatch account string
-c creatorMatch creator (four-character code)
-C typeMatch type (four-character code)
-D kindMatch kind string
-G valueMatch value string (generic attribute)
-j commentMatch comment string
-l labelMatch label string
-s serviceMatch service string
Sets the "partition list" for a generic password. The "partition list" is an extra parameter in the ACL which limits access to the item based on an application's code signature. You must present the keychain's password to change a partition list.
set-internet-password-partition-list [-a account] [-s server] [-S partition-list] [-k password] [options...] [keychain]
-S partition-listComma-separated partition list. See output of "security dump-keychain" for examples.
-k passwordPassword for keychain (deprecated)
-a accountMatch account string
-c creatorMatch creator (four-character code)
-C typeMatch type (four-character code)
-d securityDomainMatch securityDomain string
-D kindMatch kind string
-j commentMatch comment string
-l labelMatch label string
-p pathMatch path string
-P portMatch port number
-r protocolMatch protocol (four-character code)
-s serverMatch server string
-t authenticationTypeMatch authenticationType (four-character code)
Sets the "partition list" for an internet password. The "partition list" is an extra parameter in the ACL which limits access to the item based on an application's code signature. You must present the keychain's password to change a partition list.
set-key-partition-list [-S partition-list] [-k password] [options...] [keychain]
-S partition-listComma-separated partition list. See output of "security dump-keychain" for examples.
-k passwordPassword for keychain (deprecated)
-a application-labelMatch "application label" string
-c creatorMatch creator (four-character code)
-dMatch keys that can decrypt
-D descriptionMatch "description" string
-eMatch keys that can encrypt
-j commentMatch comment string
-l labelMatch label string
-rMatch keys that can derive
-sMatch keys that can sign
-t typeType of key to find: one of "symmetric", "public", or "private"
-uMatch keys that can unwrap
-vMatch keys that can verify
-wMatch keys that can wrap
Sets the "partition list" for a key. The "partition list" is an extra parameter in the ACL which limits access to the key based on an application's code signature. You must present the keychain's password to change a partition list. If you'd like to run /usr/bin/codesign with the key, "apple:" must be an element of the partition list.
find-certificate [-h] [-a] [-c name] [-e emailAddress] [-m] [-p] [-Z] [keychain...]
Options:
-aFind all matching certificates, not just the first one
-c nameMatch onname when searching (optional)
-e emailAddressMatch onemailAddress when searching (optional)
-mShow the email addresses in the certificate
-pOutput certificate in pem format. Default is to dump the attributes and keychain the cert is in.
-ZPrint SHA-256 (and SHA-1) hash of the certificate
Examples
Exports all certificates from all keychains into a pem file called allcerts.pem.
Exports all certificates from all keychains with the email address [email protected] into a pem file called certs.pem.
Print the SHA-256 hash of every certificate in 'login.keychain' whose common name includes 'MyName'
Find a certificate item. If nokeychain arguments are provided, the default search list is used.
find-identity [-h] [-p policy] [-s string] [-v] [keychain...]
Options:
-p policySpecifypolicy to evaluate (multiple -p options are allowed). Supported policies: basic, ssl-client, ssl-server, smime, eap, ipsec, ichat, codesigning, sys-default, sys-kerberos-kdc
-s stringSpecify optional policy-specificstring (e.g. a DNS hostname for SSL, or RFC822 email address for S/MIME)
-vShow valid identities only (default is to show all identities)
Examples
Display valid identities that can be used for SSL client authentication
Display identities for a SSL server running on the host 'www.domain.com'
Display identities that can be used to sign a message from '[email protected]'
Find an identity (certificate + private key) satisfying a given policy. If nopolicy arguments are provided, the X.509 basic policy is assumed. If nokeychain arguments are provided, the default search list is used.
delete-certificate [-h] [-c name] [-Z hash] [-t] [keychain...]
-c nameSpecify certificate to delete by its common name
-Z hashSpecify certificate to delete by its SHA-256 (or SHA-1) hash
-tAlso delete user trust settings for this certificate
The certificate to be deleted must be uniquely specified either by a string found in its common name, or by its SHA-256 (or SHA-1) hash.
Delete a certificate from a keychain. If nokeychain arguments are provided, the default search list is used.
delete-identity [-h] [-c name] [-Z hash] [-t] [keychain...]
-c nameSpecify certificate to delete by its common name
-Z hashSpecify certificate to delete by its SHA-256 (or SHA-1) hash
-tAlso delete user trust settings for this identity certificate
The identity to be deleted must be uniquely specified either by a string found in its common name, or by its SHA-256 (or SHA-1) hash.
Delete a certificate and its private key from a keychain. If nokeychain arguments are provided, the default search list is used.
set-identity-preference [-h] [-n] [-c identity] [-s service] [-u keyUsage] [-Z hash] [keychain...]
-nSpecify no identity (clears existing preference for the given service)
-c identitySpecify identity by common name of the certificate
-s serviceSpecify service (may be a URL, RFC822 email address, DNS host, or other name) for which this identity is to be preferred
-u keyUsageSpecify key usage (optional)
-Z hashSpecify identity by SHA-256 (or SHA-1) hash of certificate (optional)
The identity is located by searching the specified keychain(s) for a certificate whose common name contains the given identity string. If no keychains are specified to search, the default search list is used. Different identity preferences can be set for individual key usages. You can differentiate between two identities which contain the same string by providing a SHA-256 (or SHA-1) hash of the certificate in addition to, or instead of, the name.
PARTIAL PATHS AND WILDCARDS
Prior to 10.5.4, identity preferences for SSL/TLS client authentication could only be set on a per-URL basis. The URL being visited had to match the service name exactly for the preference to be in effect.
In 10.5.4, it became possible to specify identity preferences on a per-server basis, by using a service name with a partial path URL to match more specific paths on the same server. For example, if an identity preference for "https://www.apache-ssl.org/" exists, it will be in effect for "https://www.apache-ssl.org/cgi/cert-export", and so on. Note that partial path URLs must end with a trailing slash character.
Starting with 10.6, it is possible to specify identity preferences on a per-domain basis, by using the wildcard character '*' as the leftmost component of the service name. Unlike SSL wildcards, an identity preference wildcard can match more than one subdomain. For example, an identity preference for the name "*.army.mil" will match "server1.subdomain1.army.mil" or "server2.subdomain2.army.mil". Likewise, a preference for "*.mil" will match both "server.army.mil" and "server.navy.mil".
KEY USAGE CODES
0 - preference is in effect for all possible key usages (default)
1 - encryption only
2 - decryption only
4 - signing only
8 - signature verification only
16 - signing with message recovery only
32 - signature verification with message recovery only
64 - key wrapping only
128 - key unwrapping only
256 - key derivation only
Set the preferred identity to use for a service.
get-identity-preference [-h] [-s service] [-u keyUsage] [-p] [-c] [-Z]
-s serviceSpecify service (may be a URL, RFC822 email address, DNS host, or other name)
-u keyUsageSpecify key usage (optional)
-pOutput identity certificate in pem format
-cPrint common name of the preferred identity certificate
-ZPrint SHA-256 (and SHA-1) hash of the preferred identity certificate
Get the preferred identity to use for a service.
create-db [-aho0] [-g dl|cspdl] [-m mode] [name]
Options:
-aTurn off autocommit
-g dl|cspdlUse the AppleDL (default) or AppleCspDL
-m modeSet the file permissions tomode .
-oForce using openparams argument
-0Force using version 0 openparams
Examples
Create a db using the DL. If name isn't provided security will prompt the user to type a name.
export [-k keychain] [-t type] [-f format] [-w] [-p] [-P passphrase] [-o outfile]
Options:
-k keychainSpecify keychain from which item(s) will be exported.
-t typeSpecify the type of items to export. Possible types are certs, allKeys, pubKeys, privKeys, identities, and all. The default is all. An identity consists of both a certificate and the corresponding private key.
-f formatSpecify the format of the exported data. Possible formats are openssl, bsafe, pkcs7, pkcs8, pkcs12, x509, openssh1, openssh2, and pemseq. The default is pemseq if more than one item is being exported. The default is openssl if one key is being exported. The default is x509 if one certificate is being exported.
-wSpecifies that private keys are to be wrapped on export.
-pSpecifies that PEM armour is to be applied to the output data.
-P passphraseSpecify the wrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
-o outfileWrite the output data to outfile . Default is to write data to stdout.
Examples
Export one or more items from a keychain to one of a number of external representations. If keychain isn't provided, items will be exported from the user's default keychain.
import inputfile [-k keychain] [-t type] [-f format] [-w] [-P passphrase] [options...]
Options:
-k keychainSpecify keychain into which item(s) will be imported.
-t typeSpecify the type of items to import. Possible types are cert, pub, priv, session, cert, and agg. Pub, priv, and session refer to keys; agg is one of the aggregate types (pkcs12 and PEM sequence). The command can often figure out what item_type an item contains based in the filename and/or item_format.
-f formatSpecify the format of the exported data. Possible formats are openssl, bsafe, raw, pkcs7, pkcs8, pkcs12, x509, openssh1, openssh2, and pemseq. The command can often figure out what format an item is in based in the filename and/or item_type.
-wSpecify that private keys are wrapped and must be unwrapped on import.
-xSpecify that private keys are non-extractable after being imported.
-P passphraseSpecify the unwrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
-a attrName attrValueSpecify optional extended attribute name and value. Can be used multiple times. This is only valid when importing keys.
-AAllow any application to access the imported key without warning (insecure, not recommended!)
-T appPathSpecify an application which may access the imported key (multiple-T options are allowed)
Examples
Import one or more items from inputfile into a keychain. If keychain isn't provided, items will be imported into the user's default keychain.
cms [-C|-D|-E|-S] [options...]
Decoding options:
-c contentuse this detached content file
-h levelgenerate email headers with info about CMS message (outputlevel >= 0)
-nsuppress output of content
Encoding options:
-r id,...create envelope for comma-delimited list of recipients, where id can be a certificate nickname or email address
-Ginclude a signing time attribute
-H hashhash = MD2|MD4|MD5|SHA1|SHA256|SHA384|SHA512 (default: SHA1)
-N nickuse certificate named "nick" for signing
-Pinclude a SMIMECapabilities attribute
-Tdo not include content in CMS message
-Y nickinclude an EncryptionKeyPreference attribute with certificate (use "NONE" to omit)
-Z hashfind a certificate by subject key ID
Common options:
-e envelopespecify envelope file (valid with-D or-E )
-k keychainspecify keychain to use
-i infileuse infile as source of data (default: stdin)
-o outfileuse outfile as destination of data (default: stdout)
-p passworduse password as key db password (default: prompt)
-spass data a single byte at a time to CMS
-u certusageset type of certificate usage (default: certUsageEmailSigner)
-vprint debugging information
Cert usage codes:
0 - certUsageSSLClient
1 - certUsageSSLServer
2 - certUsageSSLServerWithStepUp
3 - certUsageSSLCA
4 - certUsageEmailSigner
5 - certUsageEmailRecipient
6 - certUsageObjectSigner
7 - certUsageUserCertImport
8 - certUsageVerifyCA
9 - certUsageProtectedObjectSigner
10 - certUsageStatusResponder
11 - certUsageAnyCA
Encode or decode CMS messages.
-Ccreate a CMS encrypted message
-Ddecode a CMS message
-Ecreate a CMS enveloped message
-Screate a CMS signed message
install-mds
Install (or re-install) the Module Directory Services (MDS) database. This is a system tool which is not normally used by users. There are no options.
add-trusted-cert [-d] [-r resultType] [-p policy] [-a appPath] [-s policyString] [-e allowedError] [-u keyUsage] [-k keychain] [-i settingsFileIn] [-o settingsFileOut] [certFile]
Options:
-dAdd to admin cert store; default is user.
-r resultTyperesultType = trustRoot|trustAsRoot|deny|unspecified; default is trustRoot.
-p policySpecify policy constraint (ssl, smime, codeSign, IPSec, basic, swUpdate, pkgSign, eap, macappstore, appleID, timestamping).
-a appPathSpecify application constraint.
-s policyStringSpecify policy-specific string.
-e allowedErrorSpecify allowed error (an integer value, or one of: certExpired, hostnameMismatch)
-u keyUsageSpecify key usage, an integer.
-k keychainSpecify keychain to which cert is added.
-i settingsFileInInput trust settings file; default is user domain.
-o settingsFileOutOutput trust settings file; default is user domain.
Key usage codes:
-1 - Any
1 - Sign
2 - Encrypt/Decrypt Data
4 - Encrypt/Decrypt Key
8 - Sign certificate
16 - Sign revocation
32 - Key exchange
To specify more than one usage, add values together (except -1 - Any).
Examples
security> add-trusted-cert /tmp/cert.der
security> add-trusted-cert -d .tmp/cert.der
Add certificate (in DER or PEM format) from certFile to per-user or local Admin Trust Settings. When modifying per-user Trust Settings, user authentication is required via an authentication dialog. When modifying admin Trust Settings, the process must be running as root, or admin authentication is required.
remove-trusted-cert [-d] certFile
Options:
-dRemove from admin cert store; default is user.
Remove certificate (in DER or PEM format) in certFile from per-user or local Admin Trust Settings. When modifying per-user Trust Settings, user authentication is required via an authentication dialog. When modifying admin Trust Settings, the process must be running as root, or admin authentication is required.
dump-trust-settings [-s] [-d]
Options:
-sDisplay trusted system certs; default is user.
-dDisplay trusted admin certs; default is user.
Display Trust Settings.
user-trust-settings-enable [-d] [-e]
Options:
-dDisable user-level Trust Settings.
-eEnable user-level Trust Settings.
Display or manipulate user-level Trust Settings. With no arguments, shows the current state of the user-level Trust Settings enable. Otherwise enables or disables user-level Trust Settings.
trust-settings-export [-s] [-d] settings_file
Options:
-sExport system Trust Settings; default is user.
-dExport admin Trust Settings; default is user.
Export Trust Settings to the specified file.
trust-settings-import [-d] settings_file
Options:
-dImport admin Trust Settings; default is user.
Import Trust Settings from the specified file. When modifying per-user Trust Settings, user authentication is required via an authentication dialog. When modifying admin Trust Settings, the process must be running as root, or admin authentication is required.
verify-cert [options...] [url]
Options:
-c certFileCertificate to verify, in DER or PEM format. Can be specified more than once; leaf certificate has to be specified first.
-r rootCertFileRoot certificate, in DER or PEM format. Can be specified more than once. If not specified, the system anchor certificates are used. If one root certificate is specified, and zero (non-root) certificates are specified, the root certificate is verified against itself.
-p policySpecify verification policy (ssl, smime, codeSign, IPSec, basic, swUpdate, pkgSign, eap, appleID, macappstore, timestamping). Default is basic.
-CSpecify this evaluation is for client usage, if the verification policy (e.g. ssl) distinguishes between client and server usage. Default is server usage.
-d dateDate to set for verification. Specified in the format of YYYY-MM-DD-hh:mm:ss (time optional). e.g: 2016-04-25-15:59:59 for April 25, 2016 at 3:59:59 pm in GMT
-k keychainKeychain to search for intermediate CA certificates. Can be specified multiple times. Default is the current user's keychain search list.
-n nameSpecify a name to be verified, e.g. the SSL host name for the ssl policy, or RFC822 email address for the smime policy. For backward compatibility, if the -n option is provided without an argument, it will be interpreted as equivalent to -N.
-NAvoid searching any keychains.
-LUse local certificates only. If an issuing CA certificate is missing, this option will avoid accessing the network to fetch it.
-lSpecifies that the leaf certificate is a CA cert. By default, a leaf certificate with a Basic Constraints extension with the CA bit set fails verification.
-e emailAddressSpecify email address for the smime policy. (This option is deprecated; use -n instead.)
-s sslHostSpecify SSL host name for the ssl policy. (This option is deprecated; use -n instead.)
-qQuiet, no stdout or stderr.
-R revCheckOptionSpecify a revocation checking option for this evaluation (ocsp, require, offline). Can be specified multiple times; e.g. to enable revocation checking via the OCSP method and require a positive response, use "-R ocsp -R require". The offline option will consult previously cached responses, but will not make a request to a revocation server.
-POutput the constructed certificate chain in PEM format.
-tOutput certificate contents as text.
-vSpecify verbose output, including per-certificate trust results.
Examples
Verify one or more certificates. If a direct URL argument is provided, a TLS connection is attempted and the certificate presented by that server is evaluated according to standard SSL server policy; other certificates or policy options will be ignored in this case.
authorize [options...] right...
Options:
-uAllow user interaction.
-pAllow returning partial rights.
-dDestroy acquired rights.
-PPre-authorize rights only.
-lOperate authorization in least privileged mode.
-iInternalize authref passed on stdin.
-eExternalize authref to stdout
-wWait while holding AuthorizationRef until stdout is closed. This will allow client to read externalized AuthorizationRef from pipe.
Examples
Basic authorization of my-right.
Authorizing a right and passing it to another command as a way to add authorization to shell scripts.
Authorize requested right(s). The extend-rights flag will be passed by default.
authorizationdb read <right-name>
authorizationdb write <right-name> [allow|deny|<rulename>]
authorizationdb remove <right-name>
Examples
Read definition of system.privilege.admin right.
Set system.preferences to definition of system.privilege.admin right.
Every change to preferences requires an Admin user to authenticate.
Read/Modify authorization policy database. Without a rulename write will read a dictionary as a plist from stdin.
execute-with-privileges <program> [args...]
Execute tool with privileges. On success stdin will be read and forwarded to the tool.
leaks [-cycles] [-nocontext] [-nostacks] [-exclude symbol]
Options:
-cyclesUse a stricter algorithm (See leaks(1) for details).
-nocontextWithhold the hex dumps of the leaked memory.
-nostacksDon't show stack traces of leaked memory.
-exclude symbolIgnore leaks called from symbol.
Run /usr/bin/leaks on this process. This can help find memory leaks after running certain commands.
smartcards token [-l] [-e token] [-d token]
Options:
-lList disabled smartcard tokens.
-e tokenEnable smartcard token.
-d tokenDisable smartcard token.
To list tokens available in the system
Examples
Enable, disable or list disabled smartcard tokens.
list-smartcards
Displayid s of available smartcards.
export-smartcard token [-i id] [-t type] [-e exportPath]
Options:
-i idExport/display items from token specified by tokenid , availableid s can be listed by list-smartcards command.
-t certs|privKeys|identities|allDisplay items of the specified type (Default:all )
-e exportPathSpecify path to export certificates and public keys. IfexportPath
is specified screen output is suppressed. This option cannot be combined with -t option.
Export/display items from a smartcard. If id isn't provided, items from all smartcards will be displayed.
error [error-code...]
Display an error string for the given security-related error code. The error can be in decimal or hex, e.g. 1234 or 0x1234. Multiple errors can be separated by spaces.
MallocStackLogging
When using the leaks command or the -l option it's probably a good idea to set this environment variable before security is started. Doing so will allow leaks to display symbolic backtraces.
~/Library/Preferences/com.apple.security.plist
Property list file containing the current user's default keychain and keychain search list.
/Library/Preferences/com.apple.security.plist
Property list file containing the system default keychain and keychain search list. This is used by processes started at boot time, or those requesting to use the system search domain, such as system daemons.
/Library/Preferences/com.apple.security-common.plist
Property list file containing the common keychain search list, which is appended to every user's search list and to the system search list.
126 releases since Mac OS X 10.3; the text changed 11 times.