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. New commands
25 are constantly being added over time.
31 supplied and report if anything went wrong.
39 will enter interactive mode and allow the user to enter multiple commands on stdin. When EOF is read from stdin
43 Here is a complete list of the options available:
44 .Bl -tag -width -indent
46 If no arguments are specified show a list of all commands. If arguments are provided show usage for each the specified commands. This options is basically the same as the
52 in interactive mode. A prompt
57 will be displayed and the user will be able to type commands on stdin until an EOF is encountered.
62 .Dl "/usr/bin/leaks -nocontext"
63 on itself to see if the command(s) you executed leaks.
65 This option implies the
67 option but changes the default prompt to the argument specified instead.
78 .Sh "SECURITY COMMAND SUMMARY"
80 provides a rich variety of commands
84 , each of which often has a wealth of options, to allow access to
85 the broad functionality provided by the Security framework. However,
86 you don't have to master every detail for
90 Here are brief descriptions of all the
94 .Bl -tag -width find-internet-password -compact
96 Show all commands. Or show usage for a command.
98 Display or manipulate the keychain search list.
99 .It Nm default-keychain
100 Display or set the default keychain.
101 .It Nm login-keychain
102 Display or set the login keychain.
103 .It Nm create-keychain
104 Create keychains and add them to the search list.
105 .It Nm delete-keychain
106 Delete keychains and remove them from the search list.
108 Lock the specified keychain.
109 .It Nm unlock-keychain
110 Unlock the specified keychain.
111 .It Nm set-keychain-settings
112 Set Nm settings for a keychain.
113 .It Nm show-keychain-info
114 Show the settings for keychain.
116 Dump the contents of one or more keychains.
117 .It Nm create-keypair
118 Create an asymmetric keypair.
119 .It Nm add-internet-password
120 Add an internet password item.
121 .It Nm add-certificates
122 Add certificates to a keychain.
123 .It Nm find-internet-password
124 Find an internet password item.
125 .It Nm find-certificate
126 Find a certificate item.
128 Create an db using the DL.
130 Import item(s) into a keychain.
132 Export item(s) from a keychain.
134 Install (or re-install) the MDS database.
140 Verify certificate(s).
142 .Sh "COMMON COMMAND OPTIONS"
143 This section describes the
145 that are available across all
148 .Bl -tag -width -indent
150 Show a usage message for the specified command. This option is
151 basically the same as the
155 .Sh "SECURITY COMMANDS"
156 Here (finally) are details on all the
158 commands and the options each accepts.
163 .Bl -item -offset -indent
164 Show all commands. Or show usage for a command.
169 .Op Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
170 .Op Fl s Op Ar keychain...
171 .Bl -item -offset -indent
172 Display or set the keychain search list.
175 .Bl -tag -compact -width -indent
176 .It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
177 Specify the preferences domain to be used.
179 Set the search list to the specified keychains
185 .Op Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
186 .Op Fl s Op Ar keychain
187 .Bl -item -offset -indent
188 Display or set the default keychain.
191 .Bl -tag -compact -width -indent
192 .It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
193 Specify the preferences domain to be used.
195 Set the default keychain to the specified
197 Unset it if no keychain is specified.
203 .Op Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
204 .Op Fl s Op Ar keychain
205 .Bl -item -offset -indent
206 Display or set the login keychain.
209 .Bl -tag -compact -width -indent
210 .It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
211 Specify the preferences domain to be used.
213 Set the login keychain to the specified
215 Unset it if no keychain is specified.
223 .Bl -item -offset -indent
224 Create keychains and add them to the search list. If no keychains are specified the user is prompted for one.
225 Use of the -p option is insecure.
228 .Bl -tag -compact -width -indent-indent
230 Prompt the user for a password using the SecurityAgent.
234 as the password for the keychains being created.
241 are specified the user is prompted for a password.
247 .Bl -item -offset -indent
248 Delete keychains and remove them from the search list.
253 .Op Fl a Ns | Ns Ar keychain
254 .Bl -item -offset -indent
257 \&. Or the default is none is specified. If the
259 options is specified all keychains are locked.
266 .Bl -item -offset -indent
269 \&. Or the default is none is specified.
272 .Nm set-keychain-settings
276 .Bl -item -offset -indent
279 \&. Or the default is none is specified.
280 .Bl -tag -compact -width -indent-indent
282 Lock keychain when the system sleeps
284 Lock keychain after certain period of time specified using
288 Automatically lock keychain after
290 seconds of inactivity.
294 .Nm show-keychain-info
296 .Bl -item -offset -indent
297 Show the settings for keychain.
302 .Bl -item -offset -indent
303 Dump the contents of one or more keychains.
304 .Bl -tag -compact -width -indent-indent
308 Dump cleartext data of items.
310 Interactive acl editing mode.
312 Dump raw (possibly ciphertext) data of items.
320 .Op Fl f Ar from_date
325 .Op Fl A Ns | Ns Fl T Ar app1:app2:...
326 .Bl -item -offset -indent
327 Create an asymmetric keypair.
330 .Nm add-internet-password
332 .Op Fl a Ar account_name
333 .Op Fl d Ar security_domain
337 .Op Fl s Ar server_name
338 .Op Fl t Ar authentication_type
339 .Op Fl w Ar password_data
341 .Bl -item -offset -indent
342 Add an internet password item.
349 .Bl -item -offset -indent
350 Add certficates contained in the specified
352 to the default keychain. The files must contain one DER encoded X509 certificate each.
353 .Bl -tag -compact -width -indent-indent
357 rather than the default keychain.
361 .Nm find-internet-password
363 .Op Fl a Ar account_name
364 .Op Fl d Ar security_domain
368 .Op Fl s Ar server_name
369 .Op Fl t Ar authentication_type
371 .Bl -item -offset -indent
372 Find an internet password item.
377 .Op Fl e Ar email_address
379 .Bl -item -offset -indent
380 Find a certificate item. If no
382 arguments are provided,
384 will search the default search list.
387 .Bl -tag -compact -width -indent
389 Find all matching certificates, not just the first one.
390 .It Fl g Ar dl Ns | Ns Ar cspdl
391 Use the AppleDL (default) or AppleCspDL
392 .It Fl e Ar email_address
393 Match on "email_address" when searching.
395 Show the email addresses in the certificate.
397 Output certificate in pem form. The default is to dump the attributes and keychain the cert is in.
401 .Bl -tag -width -indent
402 .Dl security> find-certificate -a -p > allcerts.pem
403 Exports all certificates from all keychains into a pem file called allcerts.pem.
404 .Dl security> find-certificate -a -e me@foo.com -p > certs.pem
405 Exports all certificates from all keychains with the email address
406 mb@foo.com into a pem file called certs.pem.
412 .Op Fl g Ar dl Ns | Ns Ar cspdl
415 .Bl -item -offset -indent
416 Create an db using the DL. If
420 will prompt the user to type a name.
423 .Bl -tag -compact -width -indent-indent
426 .It Fl g Ar dl Ns | Ns Ar cspdl
427 Use the AppleDL (default) or AppleCspDL
429 Set the file permissions to
433 Force using openparams argument
435 Force using version 0 openparams
439 .Bl -tag -width -indent
440 .Dl security> create-db -m 0644 test.db
441 .Dl security> create-db -g cspdl -a test2.db
443 .\"new import/export commands.
448 .Op Fl t Ar item_type
449 .Op Fl f Ar item_format
451 .Op Fl p Ar item_format
452 .Op Fl P Ar passphrase
454 .Bl -item -offset -indent
455 Export one or more items from a keychain to one of a number of external representations. If
457 isn't provided, items will be exported from the user's default keychain.
460 .Bl -tag -compact -width -indent-indent
462 Specify keychain from which item(s) will be exported.
463 .It Fl t Ar item_type
464 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 provate key.
465 .It Fl f Ar item_format
466 Specify the format of the exported data. Possible formats are openssl, bsafe, pkcs7, pkcs8, pkcs12, x509, 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.
468 Specifies that private keys are to be wrapped on export.
470 Specifies that PEM armour is to be applied to the output data.
471 .It Fl P Ar passphrase
472 Specify the wrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
473 Use of the -P option is unsecure.
475 Write the output data to
477 \&. Default is to write data to stdout.
481 .Bl -tag -width -indent
482 .Dl security> export -k login.keychain -t certs -o /tmp/certs.pem
483 .Dl security> export -k newcert.keychain -t identities -f pkcs12 -o /tmp/mycerts.p12
491 .Op Fl t Ar item_type
492 .Op Fl f Ar item_format
494 .Op Fl P Ar passphrase
495 .Bl -item -offset -indent
496 Import one or more items from
498 \& into a keychain. If
500 isn't provided, items will be imported into the user's default keychain.
503 .Bl -tag -compact -width -indent-indent
505 Specify keychain into which item(s) will be imported.
506 .It Fl t Ar item_type
507 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.
508 .It Fl f Ar item_format
509 Specify the format of the exported data. Possible formats are openssl, bsafe, raw, pkcs7, pkcs8, pkcs12, x509, and pemseq. The command can often figure out what format an item is in based in the filename and/or item_type.
511 Specifies that private keys are wrapped and must be unwrapped on import.
512 .It Fl P Ar passphrase
513 Specify the unwrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
514 Use of the -P option is unsecure.
518 .Bl -tag -width -indent
519 .Dl security> import /tmp/certs.pem -k
520 .Dl security> import /tmp/mycerts.p12 -t agg -k newcert.keychain
521 .Dl security> import /tmp/mycerts.p12 -f pkcs12 -k newcert.keychain
523 .\"end of new import/export commands.
526 .Bl -item -offset -indent
527 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.
535 .Op Fl exclude Ar symbol
536 .Bl -item -offset -indent
539 on this proccess. This is to help find memory leaks after running
543 .Bl -tag -compact -width -indent-indent
545 Use a stricter algorithm (See
549 Withhold the hex dumps of the leaked memory.
551 Don't show stack traces of leaked memory.
552 .It Fl exclude Ar symbol
553 Ignore leaks called from
560 .Op Fl r Ar rootCertFile
567 .Op Fl R Ar revCheckOption
568 .Bl -item -offset -indent
569 Verify one or more certificates.
572 .Bl -tag -compact -width -indent-indent
574 Certificate to verify, in DER or PEM format. Can be specified more than once; leaf certificate has to be specified first.
575 .It Fl r Ar rootCertFile
576 Root certificate, in DER or PEM format. Can be specified more than once. If not specified, the system anchor certificates are used.
578 Specify verification policy (ssl, smime, codeSign, IPSec, basic, eap, appleID, timestamping, revocation). Default is basic.
580 Specify this evaluation is for client usage, if the verification policy (e.g. ssl) distinguishes between client and server usage. Default is server usage.
582 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
584 Specify a name to be verified, e.g. the SSL host name for the ssl policy, or RFC822 email address for the smime policy.
586 Use local certificates only. If an issuing CA certificate is missing, this option will avoid accessing the network to fetch it.
588 Quiet, no stdout or stderr.
589 .It Fl R Ar revCheckOption
590 Specify a revocation checking option for this evaluation (ocsp, require, offline). Can be specified multiple times; e.g. to check revocation via OCSP 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.
594 .Bl -tag -width -indent
595 .It security> verify-cert -c applestore0.cer -c applestore1.cer -p ssl -n store.apple.com
596 .It security> verify-cert -r serverbasic.crt
598 .Sh ENVIRONMENT \" May not be needed
599 .Bl -tag -width -indent
600 .It Ev MallocStackLogging
605 option it's probably a good idea to set this environment variable before
607 is started. Doing so will allow leaks to display symbolic backtraces.
610 .Bl -tag -width -indent
611 .It Pa ~/Library/Preferences/com.apple.security.plist
613 Propertylist file containing the current users default keychain and keychain search list.
614 .It Pa /Library/Preferences/com.apple.security.plist
616 Propertylist file containing the system default keychain and keychain search list. This is used by processes started at boottime, or those requesting to use the system search domain, such as system daemons.
617 .It Pa /Library/Preferences/com.apple.security-common.plist
619 Propertylist file containing the a common keychain search list which is appended to every users searchlist and to the system search list as well.
622 .\" List links in ascending order by section, alphabetically within a section.
623 .\" Please do not reference files that do not exist without filing a bug report
626 .\" .Xr systemkeychain 8
629 was first introduced in Mac OS X version 10.3
632 still needs a lot more commands before it can be considered complete.
633 In particular it should someday supersede both the