1 .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
3 .\"man mdoc.samples for a complete listing of options
4 .\"man mdoc for the short list of editing options
5 .Dd March 15, 2017 \" DATE
6 .Dt security 1 \" Program name and manual section number
8 .Sh NAME \" Section Header - required - don't modify
10 .\" The following lines are read in generating the apropos(man -k) database. Use only key
11 .\" words here as the database is built based on the words here and in the .ND line.
12 .\" Use .Nm macro to designate other names for the documented program.
13 .Nd Command line interface to keychains and Security framework
14 .Sh SYNOPSIS \" Section Header - required - don't modify
16 .Op Fl hilqv \" [-hilqv]
17 .Op Fl p Ar prompt \" [-p prompt]
18 .Op Ar command \" [command]
19 .Op Ar command_options \" [command_options]
20 .Op Ar command_args \" [command_args]
21 .Sh DESCRIPTION \" Section Header - required - don't modify
22 A simple command line interface which lets you administer keychains,
23 manipulate keys and certificates, and do just about anything the
24 Security framework is capable of from the command line.
30 supplied and report if anything went wrong.
38 will enter interactive mode and allow the user to enter multiple commands on stdin. When EOF is read from stdin
42 Here is a complete list of the options available:
43 .Bl -tag -width -indent
45 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
51 in interactive mode. A prompt
56 will be displayed and the user will be able to type commands on stdin until an EOF is encountered.
61 .Dl "/usr/bin/leaks -nocontext"
62 on itself to see if the command(s) you executed had any leaks.
64 This option implies the
66 option but changes the default prompt to the argument specified instead.
77 .Sh "SECURITY COMMAND SUMMARY"
79 provides a rich variety of commands
83 , each of which often has a wealth of options, to allow access to
84 the broad functionality provided by the Security framework. However,
85 you don't have to master every detail for
89 Here are brief descriptions of all the
93 .Bl -tag -width user-trust-settings-enable -compact
95 Show all commands, or show usage for a command.
97 Display or manipulate the keychain search list.
98 .It Nm default-keychain
99 Display or set the default keychain.
100 .It Nm login-keychain
101 Display or set the login keychain.
102 .It Nm create-keychain
104 .It Nm delete-keychain
105 Delete keychains and remove them from the search list.
107 Lock the specified keychain.
108 .It Nm unlock-keychain
109 Unlock the specified keychain.
110 .It Nm set-keychain-settings
111 Set settings for a keychain.
112 .It Nm set-keychain-password
113 Set password for a keychain.
114 .It Nm show-keychain-info
115 Show the settings for keychain.
117 Dump the contents of one or more keychains.
118 .It Nm create-keypair
119 Create an asymmetric key pair.
120 .It Nm add-generic-password
121 Add a generic password item.
122 .It Nm add-internet-password
123 Add an internet password item.
124 .It Nm add-certificates
125 Add certificates to a keychain.
126 .It Nm find-generic-password
127 Find a generic password item.
128 .It Nm delete-generic-password
129 Delete a generic password item.
130 .It Nm set-generic-password-partition-list
131 Set the partition list of a generic password item.
132 .It Nm find-internet-password
133 Find an internet password item.
134 .It Nm delete-internet-password
135 Delete an internet password item.
136 .It Nm set-internet-password-partition-list
137 Set the partition list of a internet password item.
139 Find keys in the keychain
140 .It Nm set-key-partition-list
141 Set the partition list of a key.
142 .It Nm find-certificate
143 Find a certificate item.
145 Find an identity (certificate + private key).
146 .It Nm delete-certificate
147 Delete a certificate from a keychain.
148 .It Nm delete-identity
149 Delete a certificate and its private key from a keychain.
150 .It Nm set-identity-preference
151 Set the preferred identity to use for a service.
152 .It Nm get-identity-preference
153 Get the preferred identity to use for a service.
155 Create a db using the DL.
157 Export items from a keychain.
159 Import items into a keychain.
161 Encode or decode CMS messages.
163 Install (or re-install) the MDS database.
164 .It Nm add-trusted-cert
165 Add trusted certificate(s).
166 .It Nm remove-trusted-cert
167 Remove trusted certificate(s).
168 .It Nm dump-trust-settings
169 Display contents of trust settings.
170 .It Nm user-trust-settings-enable
171 Display or manipulate user-level trust settings.
172 .It Nm trust-settings-export
173 Export trust settings.
174 .It Nm trust-settings-import
175 Import trust settings.
177 Verify certificate(s).
179 Perform authorization operations.
180 .It Nm authorizationdb
181 Make changes to the authorization policy database.
182 .It Nm execute-with-privileges
183 Execute tool with privileges.
189 Enable, disable or list disabled smartcard tokens.
190 .It Nm list-smartcards
191 Display available smartcards.
192 .It Nm export-smartcard
193 Export items from a smartcard.
195 Display a descriptive message for the given error code(s).
197 .Sh "COMMON COMMAND OPTIONS"
198 This section describes the
200 that are available across all
203 .Bl -tag -width -indent
205 Show a usage message for the specified command. This option is
206 essentially the same as the
210 .Sh "SECURITY COMMANDS"
211 Here (finally) are details on all the
213 commands and the options each accepts.
218 .Bl -item -offset -indent
219 Show all commands, or show usage for a command.
224 .Op Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common Ns | Ns Ar dynamic
225 .Op Fl s Op Ar keychain...
226 .Bl -item -offset -indent
227 Display or manipulate the keychain search list.
229 .Bl -tag -compact -width -indent
230 .It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common Ns | Ns Ar dynamic
231 Use the specified preference domain.
233 Set the search list to the specified keychains.
239 .Op Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common Ns | Ns Ar dynamic
240 .Op Fl s Op Ar keychain
241 .Bl -item -offset -indent
242 Display or set the default keychain.
244 .Bl -tag -compact -width -indent
245 .It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common Ns | Ns Ar dynamic
246 Use the specified preference domain.
248 Set the default keychain to the specified
250 Unset it if no keychain is specified.
256 .Op Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common Ns | Ns Ar dynamic
257 .Op Fl s Op Ar keychain
258 .Bl -item -offset -indent
259 Display or set the login keychain.
261 .Bl -tag -compact -width -indent
262 .It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common Ns | Ns Ar dynamic
263 Use the specified preference domain.
265 Set the login keychain to the specified
267 Unset it if no keychain is specified.
275 .Bl -item -offset -indent
278 .Bl -tag -compact -width -indent-indent
280 Prompt the user for a password using the SecurityAgent.
284 as the password for the keychains being created.
291 are specified, the user is prompted for a password on the command line. Use
292 of the -p option is insecure.
298 .Bl -item -offset -indent
299 Delete keychains and remove them from the search list.
304 .Op Fl a Ns | Ns Ar keychain
305 .Bl -item -offset -indent
308 \&, or the default keychain if none is specified. If the
310 option is specified, all keychains are locked.
317 .Bl -item -offset -indent
320 \&, or the default keychain if none is specified.
323 .Nm set-keychain-settings
327 .Bl -item -offset -indent
330 \&, or the default keychain if none is specified.
332 .Bl -tag -compact -width -indent-indent
334 Lock keychain when the system sleeps.
336 Lock keychain after timeout interval.
340 interval in seconds (omitting this option specifies "no timeout").
344 .Nm set-keychain-password
346 .Op Fl o Ar oldPassword
347 .Op Fl p Ar newPassword
349 .Bl -item -offset -indent
352 \&, or the default keychain if none is specified.
354 .Bl -tag -compact -width -indent-indent
355 .It Fl o Ar oldPassword
356 Old keychain password (if not provided, will prompt)
357 .It Fl p Ar newPassword
358 New keychain password (if not provided, will prompt)
362 .Nm show-keychain-info
365 .Bl -item -offset -indent
366 Show the settings for
373 .Bl -item -offset -indent
374 Dump the contents of one or more keychains.
376 .Bl -tag -compact -width -indent-indent
378 Dump access control list of items
380 Dump (decrypted) data of items
382 Interactive access control list editing mode
384 Dump raw (encrypted) data of items
396 .Op Fl A Ns | Ns Fl T Ar appPath
398 .Bl -item -offset -indent
399 Create an asymmetric key pair.
401 .Bl -tag -compact -width -indent-indent
405 as the algorithm, can be rsa, dh, dsa or fee (default rsa)
407 Specify the keysize in bits (default 512)
409 Make a key valid from the specified date (ex: "13/11/10 3:30pm")
411 Make a key valid to the specified date
413 Make a key valid for the number of days specified from today
415 Use the specified keychain rather than the default
417 Allow any application to access this key without warning (insecure, not recommended!)
419 Specify an application which may access this key (multiple
421 \& options are allowed)
425 .Nm add-generic-password
432 .Bl -item -offset -indent
433 Add a generic password item.
435 .Bl -tag -compact -width -indent-indent
437 Specify account name (required)
439 Specify item creator (optional four-character code)
441 Specify item type (optional four-character code)
443 Specify kind (default is "application password")
445 Specify generic attribute value (optional)
447 Specify comment string (optional)
449 Specify label (if omitted, service name is used as default label)
451 Specify service name (required)
453 Specify password to be added (legacy option, equivalent to
457 Specify password to be added. Put at end of command to be prompted (recommended)
459 Allow any application to access this item without warning (insecure, not recommended!)
461 Specify an application which may access this item (multiple
463 \& options are allowed)
465 Update item if it already exists (if omitted, the item cannot already exist)
469 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:
471 \& "". If no keychain is specified, the password is added to the default keychain.
475 .Nm add-internet-password
482 .Bl -item -offset -indent
483 Add an internet password item.
485 .Bl -tag -compact -width -indent-indent
487 Specify account name (required)
489 Specify item creator (optional four-character code)
491 Specify item type (optional four-character code)
493 Specify security domain string (optional)
495 Specify kind (default is "application password")
497 Specify comment string (optional)
499 Specify label (if omitted, service name is used as default label)
501 Specify path string (optional)
503 Specify port number (optional)
505 Specify protocol (optional four-character SecProtocolType, e.g. "http", "ftp ")
507 Specify server name (required)
508 .It Fl t Ar authenticationType
509 Specify authentication type (as a four-character SecAuthenticationType, default is "dflt")
511 Specify password to be added. Put at end of command to be prompted (recommended)
513 Allow any application to access this item without warning (insecure, not recommended!)
515 Specify an application which may access this item (multiple
517 \& options are allowed)
519 Update item if it already exists (if omitted, the item cannot already exist)
523 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:
525 \& "". If no keychain is specified, the password is added to the default keychain.
533 .Bl -item -offset -indent
534 Add certficates contained in the specified
536 to the default keychain. The files must contain one DER encoded X509 certificate each.
537 .Bl -tag -compact -width -indent-indent
541 rather than the default keychain.
545 .Nm find-generic-password
551 .Op Fl Ar keychain...
552 .Bl -item -offset -indent
553 Find a generic password item.
555 .Bl -tag -compact -width -indent-indent
559 Match creator (four-character code)
561 Match type (four-character code)
565 Match value string (generic attribute)
573 Display the password for the item found
575 Display the password(only) for the item found
579 .Nm delete-generic-password
584 .Op Fl Ar keychain...
585 .Bl -item -offset -indent
586 Delete a generic password item.
588 .Bl -tag -compact -width -indent-indent
592 Match creator (four-character code)
594 Match type (four-character code)
598 Match value string (generic attribute)
608 .Nm delete-internet-password
614 .Bl -item -offset -indent
615 Delete an internet password item.
617 .Bl -tag -compact -width -indent-indent
621 Match creator (four-character code)
623 Match type (four-character code)
624 .It Fl d Ar securityDomain
625 Match securityDomain string
637 Match protocol (four-character code)
640 .It Fl t Ar authenticationType
641 Match authenticationType (four-character code)
645 .Nm find-internet-password
652 .Bl -item -offset -indent
653 Find an internet password item.
655 .Bl -tag -compact -width -indent-indent
659 Match creator (four-character code)
661 Match type (four-character code)
662 .It Fl d Ar securityDomain
663 Match securityDomain string
675 Match protocol (four-character code)
678 .It Fl t Ar authenticationType
679 Match authenticationType (four-character code)
681 Display the password for the item found
683 Display the password(only) for the item found
690 .Bl -item -offset -indent
691 Search the keychain for keys.
693 .Bl -tag -compact -width -indent-indent
694 .It Fl a Ar application-label
695 Match "application label" string
697 Match creator (four-character code)
699 Match keys that can decrypt
700 .It Fl D Ar description
701 Match "description" string
703 Match keys that can encrypt
709 Match keys that can derive
711 Match keys that can sign
713 Type of key to find: one of "symmetric", "public", or "private"
715 Match keys that can unwrap
717 Match keys that can verify
719 Match keys that can wrap
723 .Nm set-generic-password-partition-list
726 .Op Fl S Ar <partition list (comma separated)>
727 .Op Fl k Ar <keychain password>
730 .Bl -item -offset -indent
731 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.
733 .Bl -tag -compact -width -indent-indent
734 .It Fl S Ar partition-list
735 Comma-separated partition list. See output of "security dump-keychain" for examples.
737 Password for keychain
741 Match creator (four-character code)
743 Match type (four-character code)
747 Match value string (generic attribute)
757 .Nm set-internet-password-partition-list
760 .Op Fl S Ar <partition list (comma separated)>
761 .Op Fl k Ar <keychain password>
764 .Bl -item -offset -indent
765 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.
767 .Bl -tag -compact -width -indent-indent
768 .It Fl S Ar partition-list
769 Comma-separated partition list. See output of "security dump-keychain" for examples.
771 Password for keychain
775 Match creator (four-character code)
777 Match type (four-character code)
778 .It Fl d Ar securityDomain
779 Match securityDomain string
791 Match protocol (four-character code)
794 .It Fl t Ar authenticationType
795 Match authenticationType (four-character code)
799 .Nm set-key-partition-list
800 .Op Fl S Ar <partition list (comma separated)>
801 .Op Fl k Ar <keychain password>
804 .Bl -item -offset -indent
805 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.
807 .Bl -tag -compact -width -indent-indent
808 .It Fl S Ar partition-list
809 Comma-separated partition list. See output of "security dump-keychain" for examples.
811 Password for keychain
812 .It Fl a Ar application-label
813 Match "application label" string
815 Match creator (four-character code)
817 Match keys that can decrypt
818 .It Fl D Ar description
819 Match "description" string
821 Match keys that can encrypt
827 Match keys that can derive
829 Match keys that can sign
831 Type of key to find: one of "symmetric", "public", or "private"
833 Match keys that can unwrap
835 Match keys that can verify
837 Match keys that can wrap
845 .Op Fl e Ar emailAddress
850 .Bl -item -offset -indent
851 Find a certificate item. If no
853 \& arguments are provided, the default search list is used.
856 .Bl -tag -compact -width -indent-indent
858 Find all matching certificates, not just the first one
862 \& when searching (optional)
863 .It Fl e Ar emailAddress
866 \& when searching (optional)
868 Show the email addresses in the certificate
870 Output certificate in pem format. Default is to dump the attributes and keychain the cert is in.
872 Print SHA-1 hash of the certificate
876 .Bl -tag -width -indent
877 .It security> find-certificate -a -p > allcerts.pem
878 Exports all certificates from all keychains into a pem file called allcerts.pem.
879 .It security> find-certificate -a -e me@foo.com -p > certs.pem
880 Exports all certificates from all keychains with the email address
881 me@foo.com into a pem file called certs.pem.
882 .It security> find-certificate -a -c MyName -Z login.keychain | grep ^SHA-1
883 Print the SHA-1 hash of every certificate in 'login.keychain' whose common name includes 'MyName'
893 .Bl -item -offset -indent
894 Find an identity (certificate + private key) satisfying a given policy. If no
896 \& arguments are provided, the X.509 basic policy is assumed. If no
898 \& arguments are provided, the default search list is used.
901 .Bl -tag -compact -width -indent-indent
905 \& to evaluate (multiple -p options are allowed). Supported policies:
906 basic, ssl-client, ssl-server, smime, eap, ipsec, ichat, codesigning,
907 sys-default, sys-kerberos-kdc
909 Specify optional policy-specific
911 \& (e.g. a DNS hostname for SSL, or RFC822 email address for S/MIME)
913 Show valid identities only (default is to show all identities)
917 .Bl -tag -width -indent
918 .It security> find-identity -v -p ssl-client
919 Display valid identities that can be used for SSL client authentication
920 .It security> find-identity -p ssl-server -s www.domain.com
921 Display identities for a SSL server running on the host 'www.domain.com'
922 .It security> find-identity -p smime -s user@domain.com
923 Display identities that can be used to sign a message from 'user@domain.com'
927 .Nm delete-certificate
933 .Bl -item -offset -indent
934 Delete a certificate from a keychain. If no
936 \& arguments are provided, the default search list is used.
938 .Bl -tag -compact -width -indent-indent
940 Specify certificate to delete by its common name
942 Specify certificate to delete by its SHA-1 hash
944 Also delete user trust settings for this certificate
947 The certificate to be deleted must be uniquely specified either by a
948 string found in its common name, or by its SHA-1 hash.
957 .Bl -item -offset -indent
958 Delete a certificate and its private key from a keychain. If no
960 \& arguments are provided, the default search list is used.
962 .Bl -tag -compact -width -indent-indent
964 Specify certificate to delete by its common name
966 Specify certificate to delete by its SHA-1 hash
968 Also delete user trust settings for this identity certificate
971 The identity to be deleted must be uniquely specified either by a
972 string found in its common name, or by its SHA-1 hash.
975 .Nm set-identity-preference
983 .Bl -item -offset -indent
984 Set the preferred identity to use for a service.
986 .Bl -tag -compact -width -indent-indent
988 Specify no identity (clears existing preference for the given service)
990 Specify identity by common name of the certificate
992 Specify service (may be a URL, RFC822 email address, DNS host, or other name) for which this identity is to be preferred
994 Specify key usage (optional)
996 Specify identity by SHA-1 hash of certificate (optional)
999 The identity is located by searching the specified keychain(s) for a certificate whose common name contains
1000 the given identity string. If no keychains are specified to search, the default search list is used. Different
1001 identity preferences can be set for individual key usages. You can differentiate between two identities which contain
1002 the same string by providing a SHA-1 hash of the certificate (in addition to, or instead of, the name.)
1004 .Sy PARTIAL PATHS AND WILDCARDS
1006 Prior to 10.5.4, identity preferences for SSL/TLS client authentication could only be set on a per-URL basis. The
1007 URL being visited had to match the service name exactly for the preference to be in effect.
1009 In 10.5.4, it became possible to specify identity preferences on a per-server basis, by using
1010 a service name with a partial path URL to match more specific paths on the same server. For
1011 example, if an identity preference for "https://www.apache-ssl.org/" exists, it will be in effect for
1012 "https://www.apache-ssl.org/cgi/cert-export", and so on. Note that partial path URLs must end with a trailing
1015 Starting with 10.6, it is possible to specify identity preferences on a per-domain
1016 basis, by using the wildcard character '*' as the leftmost component of the service name. Unlike SSL wildcards,
1017 an identity preference wildcard can match more than one subdomain. For example, an identity preference for
1018 the name "*.army.mil" will match "server1.subdomain1.army.mil" or "server2.subdomain2.army.mil". Likewise,
1019 a preference for "*.mil" will match both "server.army.mil" and "server.navy.mil".
1023 .Bl -tag -width -indent
1024 0 - preference is in effect for all possible key usages (default)
1028 8 - signature verification only
1029 16 - signing with message recovery only
1030 32 - signature verification with message recovery only
1031 64 - key wrapping only
1032 128 - key unwrapping only
1033 256 - key derivation only
1034 .It To specify more than one usage, add values together.
1038 .Nm get-identity-preference
1041 .Op Fl u Ar keyUsage
1045 .Bl -item -offset -indent
1046 Get the preferred identity to use for a service.
1048 .Bl -tag -compact -width -indent-indent
1050 Specify service (may be a URL, RFC822 email address, DNS host, or other name)
1051 .It Fl u Ar keyUsage
1052 Specify key usage (optional)
1054 Output identity certificate in pem format
1056 Print common name of the preferred identity certificate
1058 Print SHA-1 hash of the preferred identity certificate
1064 .Op Fl g Ar dl Ns | Ns Ar cspdl
1067 .Bl -item -offset -indent
1068 Create a db using the DL. If
1072 will prompt the user to type a name.
1075 .Bl -tag -compact -width -indent-indent
1078 .It Fl g Ar dl Ns | Ns Ar cspdl
1079 Use the AppleDL (default) or AppleCspDL
1081 Set the file permissions to
1085 Force using openparams argument
1087 Force using version 0 openparams
1091 .Bl -tag -width -indent
1092 .It security> create-db -m 0644 test.db
1093 .It security> create-db -g cspdl -a test2.db
1095 .\"new import/export commands.
1099 .Op Fl k Ar keychain
1104 .Op Fl P Ar passphrase
1106 .Bl -item -offset -indent
1107 Export one or more items from a keychain to one of a number of external representations. If
1109 isn't provided, items will be exported from the user's default keychain.
1112 .Bl -tag -compact -width -indent-indent
1113 .It Fl k Ar keychain
1114 Specify keychain from which item(s) will be exported.
1116 Specify 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.
1118 Specify 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.
1120 Specifies that private keys are to be wrapped on export.
1122 Specifies that PEM armour is to be applied to the output data.
1123 .It Fl P Ar passphrase
1124 Specify the wrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
1126 Write the output data to
1128 \&. Default is to write data to stdout.
1132 .Bl -tag -width -indent
1133 .It security> export -k login.keychain -t certs -o /tmp/certs.pem
1134 .It security> export -k newcert.keychain -t identities -f pkcs12 -o /tmp/mycerts.p12
1141 .Op Fl k Ar keychain
1145 .Op Fl P Ar passphrase
1147 .Bl -item -offset -indent
1148 Import one or more items from
1150 \& into a keychain. If
1152 isn't provided, items will be imported into the user's default keychain.
1155 .Bl -tag -compact -width -indent-indent
1156 .It Fl k Ar keychain
1157 Specify keychain into which item(s) will be imported.
1159 Specify 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.
1161 Specify 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.
1163 Specify that private keys are wrapped and must be unwrapped on import.
1165 Specify that private keys are non-extractable after being imported.
1166 .It Fl P Ar passphrase
1167 Specify the unwrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
1168 .It Fl a Ar attrName Ar attrValue
1169 Specify optional extended attribute name and value. Can be used multiple times. This is only valid when importing keys.
1171 Allow any application to access the imported key without warning (insecure, not recommended!)
1173 Specify an application which may access the imported key (multiple
1175 \& options are allowed)
1179 .Bl -tag -width -indent
1180 .It security> import /tmp/certs.pem -k
1181 .It security> import /tmp/mycerts.p12 -t agg -k newcert.keychain
1182 .It security> import /tmp/mycerts.p12 -f pkcs12 -k newcert.keychain
1184 .\"end of new import/export commands.
1188 .Op Fl C Ns | Ns Fl D Ns | Ns Fl E Ns | Ns Fl S
1190 .Bl -item -offset -indent
1191 Encode or decode CMS messages.
1192 .Bl -tag -compact -width -indent-indent
1194 create a CMS encrypted message
1196 decode a CMS message
1198 create a CMS enveloped message
1200 create a CMS signed message
1204 .Bl -tag -compact -width -indent-indent
1206 use this detached content file
1208 generate email headers with info about CMS message (output
1212 suppress output of content
1216 .Bl -tag -compact -width -indent-indent
1218 create envelope for comma-delimited list of recipients, where id can be a certificate nickname or email address
1220 include a signing time attribute
1222 hash = MD2|MD4|MD5|SHA1|SHA256|SHA384|SHA512 (default: SHA1)
1224 use certificate named "nick" for signing
1226 include a SMIMECapabilities attribute
1228 do not include content in CMS message
1230 include an EncryptionKeyPreference attribute with certificate (use "NONE" to omit)
1232 find a certificate by subject key ID
1236 .Bl -tag -compact -width -indent-indent
1237 .It Fl e Ar envelope
1238 specify envelope file (valid with
1243 .It Fl k Ar keychain
1244 specify keychain to use
1246 use infile as source of data (default: stdin)
1248 use outfile as destination of data (default: stdout)
1249 .It Fl p Ar password
1250 use password as key db password (default: prompt)
1252 pass data a single byte at a time to CMS
1253 .It Fl u Ar certusage
1254 set type of certificate usage (default: certUsageEmailSigner)
1256 print debugging information
1260 0 - certUsageSSLClient
1261 1 - certUsageSSLServer
1262 2 - certUsageSSLServerWithStepUp
1264 4 - certUsageEmailSigner
1265 5 - certUsageEmailRecipient
1266 6 - certUsageObjectSigner
1267 7 - certUsageUserCertImport
1268 8 - certUsageVerifyCA
1269 9 - certUsageProtectedObjectSigner
1270 10 - certUsageStatusResponder
1276 .Bl -item -offset -indent
1277 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.
1280 .Nm add-trusted-cert
1282 .Op Fl r Ar resultType
1285 .Op Fl s Ar policyString
1286 .Op Fl e Ar allowedError
1287 .Op Fl u Ar keyUsage
1288 .Op Fl k Ar keychain
1289 .Op Fl i Ar settingsFileIn
1290 .Op Fl o Ar settingsFileOut
1292 .Bl -item -offset -indent
1293 Add certificate (in DER or PEM format) from
1295 \& 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.
1298 .Bl -tag -compact -width -indent-indent
1300 Add to admin cert store; default is user.
1301 .It Fl r Ar resultType
1302 resultType = trustRoot|trustAsRoot|deny|unspecified; default is trustRoot.
1304 Specify policy constraint (ssl, smime, codeSign, IPSec, basic, swUpdate, pkgSign, eap, macappstore, appleID, timestamping).
1305 .It Fl r Ar resultType
1306 resultType = trustRoot|trustAsRoot|deny|unspecified; default is trustRoot.
1308 Specify application constraint.
1309 .It Fl s Ar policyString
1310 Specify policy-specific string.
1311 .It Fl e Ar allowedError
1312 Specify allowed error (an integer value, or one of: certExpired, hostnameMismatch)
1313 .It Fl u Ar keyUsage
1314 Specify key usage, an integer.
1315 .It Fl k Ar keychain
1316 Specify keychain to which cert is added.
1317 .It Fl i Ar settingsFileIn
1318 Input trust settings file; default is user domain.
1319 .It Fl o Ar settingsFileOut
1320 Output trust settings file; default is user domain.
1323 .Sy Key usage codes:
1326 2 - Encrypt/Decrypt Data
1327 4 - Encrypt/Decrypt Key
1328 8 - Sign certificate
1329 16 - Sign revocation
1331 To specify more than one usage, add values together (except -1 - Any).
1334 .Bl -tag -width -indent
1335 .Dl security> add-trusted-cert /tmp/cert.der
1336 .Dl security> add-trusted-cert -d .tmp/cert.der
1340 .Nm remove-trusted-cert
1343 .Bl -item -offset -indent
1344 Remove certificate (in DER or PEM format) in
1346 \& 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.
1349 .Bl -tag -compact -width -indent-indent
1351 Remove from admin cert store; default is user.
1356 .Nm dump-trust-settings
1359 .Bl -item -offset -indent
1360 Display Trust Settings.
1363 .Bl -tag -compact -width -indent-indent
1365 Display trusted system certs; default is user.
1367 Display trusted admin certs; default is user.
1372 .Nm user-trust-settings-enable
1375 .Bl -item -offset -indent
1376 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.
1379 .Bl -tag -compact -width -indent-indent
1381 Disable user-level Trust Settings.
1383 Enable user-level Trust Settings.
1388 .Nm trust-settings-export
1392 .Bl -item -offset -indent
1393 Export Trust Settings to the specified file.
1396 .Bl -tag -compact -width -indent-indent
1398 Export system Trust Settings; default is user.
1400 Export admin Trust Settings; default is user.
1405 .Nm trust-settings-import
1408 .Bl -item -offset -indent
1409 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.
1412 .Bl -tag -compact -width -indent-indent
1414 Import admin Trust Settings; default is user.
1420 .Op Fl c Ar certFile
1421 .Op Fl r Ar rootCertFile
1425 .Op Fl k Ar keychain
1430 .Op Fl e Ar emailAddress
1433 .Op Fl R Ar revCheckOption
1434 .Bl -item -offset -indent
1435 Verify one or more certificates.
1438 .Bl -tag -compact -width -indent-indent
1439 .It Fl c Ar certFile
1440 Certificate to verify, in DER or PEM format. Can be specified more than once; leaf certificate has to be specified first.
1441 .It Fl r Ar rootCertFile
1442 Root 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.
1444 Specify verification policy (ssl, smime, codeSign, IPSec, basic, swUpdate, pkgSign, eap, appleID, macappstore, timestamping). Default is basic.
1446 Specify this evaluation is for client usage, if the verification policy (e.g. ssl) distinguishes between client and server usage. Default is server usage.
1448 Date 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
1449 .It Fl k Ar keychain
1450 Keychain to search for intermediate CA certificates. Can be specified multiple times. Default is the current user's keychain search list.
1452 Specify 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.
1454 Avoid searching any keychains.
1456 Use local certificates only. If an issuing CA certificate is missing, this option will avoid accessing the network to fetch it.
1458 Specifies 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.
1459 .It Fl e Ar emailAddress
1460 Specify email address for the smime policy. (This option is deprecated; use -n instead.)
1462 Specify SSL host name for the ssl policy. (This option is deprecated; use -n instead.)
1464 Quiet, no stdout or stderr.
1465 .It Fl R Ar revCheckOption
1466 Specify a revocation checking option for this evaluation (ocsp, crl, require, offline). Can be specified multiple times; e.g. to enable revocation checking via either OCSP or CRL methods and require a positive response, use "-R ocsp -R crl -R require". The offline option will consult previously cached responses, but will not make a request to a revocation server.
1470 .Bl -tag -width -indent
1471 .It security> verify-cert -c applestore0.cer -c applestore1.cer -p ssl -n store.apple.com
1472 .It security> verify-cert -r serverbasic.crt
1480 .Bl -item -offset -indent
1481 Authorize requested right(s). The extend-rights flag will be passed by default.
1484 .Bl -tag -compact -width -indent-indent
1486 Allow user interaction.
1488 Allow returning partial rights.
1490 Destroy acquired rights.
1492 Pre-authorize rights only.
1494 Operate authorization in least privileged mode.
1496 Internalize authref passed on stdin.
1498 Externalize authref to stdout
1500 Wait while holding AuthorizationRef until stdout is closed. This will allow client to read externalized AuthorizationRef from pipe.
1504 .Bl -tag -width -indent
1505 .It security> security authorize -ud my-right
1506 Basic authorization of my-right.
1507 .It security> security -q authorize -uew my-right | security -q authorize -i my-right
1508 Authorizing a right and passing it to another command as a way to add authorization to shell scripts.
1513 .Ar read <right-name>
1516 .Ar write <right-name> [allow|deny|<rulename>]
1519 .Ar remove <right-name>
1520 .Bl -item -offset -indent
1521 Read/Modify authorization policy database. Without a rulename write will read a dictionary as a plist from stdin.
1524 .Bl -tag -width -indent
1525 .It security> security authorizationdb read system.privilege.admin > /tmp/aewp-def
1526 Read definition of system.privilege.admin right.
1527 .It security> security authorizationdb write system.preferences < /tmp/aewp-def
1528 Set system.preferences to definition of system.privilege.admin right.
1529 .It security> security authorizationdb write system.preferences authenticate-admin
1530 Every change to preferences requires an Admin user to authenticate.
1534 .Nm execute-with-privileges
1537 .Bl -item -offset -indent
1538 Execute tool with privileges.
1539 On success stdin will be read and forwarded to the tool.
1547 .Op Fl exclude Ar symbol
1548 .Bl -item -offset -indent
1551 on this process. This can help find memory leaks after running
1555 .Bl -tag -compact -width -indent-indent
1557 Use a stricter algorithm (See
1561 Withhold the hex dumps of the leaked memory.
1563 Don't show stack traces of leaked memory.
1564 .It Fl exclude Ar symbol
1565 Ignore leaks called from
1575 .Bl -item -offset -indent
1576 Enable, disable or list disabled smartcard tokens.
1579 .Bl -tag -compact -width -indent-indent
1581 List disabled smartcard tokens.
1583 Enable smartcard token.
1585 Disable smartcard token.
1588 .Sy To list tokens available in the system
1590 .Bl -tag -compact -width -indent
1591 .It pluginkit -m -p com.apple.ctk-tokens
1596 .Bl -tag -compact -width -indent
1597 .It security smartcards token -l
1598 .It security smartcards token -d com.apple.CryptoTokenKit.pivtoken
1599 .It security smartcards token -e com.apple.CryptoTokenKit.pivtoken
1604 .Bl -item -offset -indent
1607 s of available smartcards.
1610 .Nm export-smartcard
1613 .Op Fl t Ar certs Ns | Ns Ar privKeys Ns | Ns Ar identities Ns | Ns Ar all
1614 .Bl -item -offset -indent
1615 Export items from a smartcard. If
1617 isn't provided, items from all smartcards will be exported.
1620 .Bl -tag -compact -width -indent-indent
1622 Export items from token specified by token
1626 s can be listed by list-smartcards command.
1627 .It Fl t Ar certs Ns | Ns Ar privKeys Ns | Ns Ar identities Ns | Ns Ar all
1628 Export items of the specified type (Default:
1636 .Op Ar <error code(s)...>
1637 .Bl -item -offset -indent
1638 Display an error string for the given security-related error code.
1639 The error can be in decimal or hex, e.g. 1234 or 0x1234. Multiple
1640 errors can be separated by spaces.
1644 .Sh ENVIRONMENT \" May not be needed
1645 .Bl -tag -width -indent
1646 .It Ev MallocStackLogging
1651 option it's probably a good idea to set this environment variable before
1653 is started. Doing so will allow leaks to display symbolic backtraces.
1656 .Bl -tag -width -indent
1657 .It Pa ~/Library/Preferences/com.apple.security.plist
1659 Property list file containing the current user's default keychain and keychain search list.
1660 .It Pa /Library/Preferences/com.apple.security.plist
1662 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.
1663 .It Pa /Library/Preferences/com.apple.security-common.plist
1665 Property list file containing the common keychain search list, which is appended to every user's search list and to the system search list.
1668 .\" List links in ascending order by section, alphabetically within a section.
1669 .\" Please do not reference files that do not exist without filing a bug report
1673 .\" .Xr systemkeychain 8
1676 was first introduced in Mac OS X version 10.3.
1679 still needs more commands before it can be considered complete.
1680 In particular, it should someday supersede both the