]> git.saurik.com Git - apple/security.git/blame - OSX/sec/SecurityTool/security.1
Security-58286.51.6.tar.gz
[apple/security.git] / OSX / sec / SecurityTool / security.1
CommitLineData
427c49bc
A
1.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2.\"See Also:
3.\"man mdoc.samples for a complete listing of options
4.\"man mdoc for the short list of editing options
866f8763 5.Dd March 15, 2017 \" DATE
427c49bc
A
6.Dt security 1 \" Program name and manual section number
7.Os Darwin
8.Sh NAME \" Section Header - required - don't modify
9.Nm security
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
15.Nm
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
22A simple command line interface which lets you administer Keychains,
23manipulate keys and certificates, and do just about anything the
24Security framework is capable of from the command line. New commands
25are constantly being added over time.
26.Pp
27By default
28.Nm
29will execute the
30.Ar command
31supplied and report if anything went wrong.
32.Pp
33If the
34.Fl i
35or
36.Fl p
37options are provided,
38.Nm
39will enter interactive mode and allow the user to enter multiple commands on stdin. When EOF is read from stdin
40.Nm
41will exit.
42.Pp
43Here is a complete list of the options available:
44.Bl -tag -width -indent
45.It Fl h
46If 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
47.Nm help
48command.
49.It Fl i
50Run
51.Nm
52in interactive mode. A prompt
53.Po
54.Li security>
55by default
56.Pc
57will be displayed and the user will be able to type commands on stdin until an EOF is encountered.
58.It Fl l
59Before
60.Nm
61exits run
62.Dl "/usr/bin/leaks -nocontext"
63on itself to see if the command(s) you executed leaks.
64.It Fl p Ar prompt
65This option implies the
66.Fl i
67option but changes the default prompt to the argument specified instead.
68.It Fl q
69Will make
70.Nm
71less verbose.
72.It Fl v
73Will make
74.Nm
75more verbose.
76.El \" Ends the list
77.Pp
78.Sh "SECURITY COMMAND SUMMARY"
79.Nm
80provides a rich variety of commands
81.Po Ar command
82in the
83.Sx SYNOPSIS Pc Ns
84, each of which often has a wealth of options, to allow access to
85the broad functionality provided by the Security framework. However,
86you don't have to master every detail for
87.Nm
88to be useful to you.
89.Pp
90Here are brief descriptions of all the
91.Nm
92commands:
93.Pp
94.Bl -tag -width find-internet-password -compact
95.It Nm help
96Show all commands. Or show usage for a command.
97.It Nm list-keychains
98Display or manipulate the keychain search list.
99.It Nm default-keychain
100Display or set the default keychain.
101.It Nm login-keychain
102Display or set the login keychain.
103.It Nm create-keychain
104Create keychains and add them to the search list.
105.It Nm delete-keychain
106Delete keychains and remove them from the search list.
107.It Nm lock-keychain
108Lock the specified keychain.
109.It Nm unlock-keychain
110Unlock the specified keychain.
111.It Nm set-keychain-settings
112Set Nm settings for a keychain.
113.It Nm show-keychain-info
114Show the settings for keychain.
115.It Nm dump-keychain
116Dump the contents of one or more keychains.
117.It Nm create-keypair
118Create an assymetric keypair.
119.It Nm add-internet-password
120Add an internet password item.
121.It Nm add-certificates
122Add certificates to a keychain.
123.It Nm find-internet-password
124Find an internet password item.
125.It Nm find-certificate
126Find a certificate item.
127.It Nm create-db
128Create an db using the DL.
129.It Nm import
130Import item(s) into a keychain.
131.It Nm export
132Export item(s) from a keychain.
133.It Nm install-mds
134Install (or re-install) the MDS database.
135.It Nm leaks
136Run
137.Pa /usr/bin/leaks
138on this proccess.
822b670c
A
139.It Nm verify-cert
140Verify certificate(s).
427c49bc
A
141.El
142.Sh "COMMON COMMAND OPTIONS"
143This section describes the
144.Ar command_options
145that are available across all
146.Nm
147commands.
148.Bl -tag -width -indent
149.It Fl h
150Show a usage message for the specified command. This option is
151basically the same as the
152.Ar help
153command.
154.El
155.Sh "SECURITY COMMANDS"
156Here (finally) are details on all the
157.Nm
158commands and the options each accepts.
159.Bl -item
160.It
161.Nm help
162.Op Fl h
163.Bl -item -offset -indent
164Show all commands. Or show usage for a command.
165.El
166.It
167.Nm list-keychains
168.Op Fl h
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
172Display or set the keychain search list.
173.It
174Options:
175.Bl -tag -compact -width -indent
176.It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
177Specify the preferences domain to be used.
178.It Fl s
179Set the search list to the specified keychains
180.El
181.El
182.It
183.Nm default-keychain
184.Op Fl h
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
188Display or set the default keychain.
189.It
190Options:
191.Bl -tag -compact -width -indent
192.It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
193Specify the preferences domain to be used.
194.It Fl s
195Set the default keychain to the specified
196.Ar keychain Ns .
197Unset it if no keychain is specified.
198.El
199.El
200.It
201.Nm login-keychain
202.Op Fl h
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
206Display or set the login keychain.
207.It
208Options:
209.Bl -tag -compact -width -indent
210.It Fl d Ar user Ns | Ns Ar system Ns | Ns Ar common
211Specify the preferences domain to be used.
212.It Fl s
213Set the login keychain to the specified
214.Ar keychain Ns .
215Unset it if no keychain is specified.
216.El
217.El
218.It
219.Nm create-keychain
220.Op Fl hP
221.Op Fl p Ar password
222.Op Ar keychain...
223.Bl -item -offset -indent
822b670c 224Create keychains and add them to the search list. If no keychains are specified the user is prompted for one.
fa7225c8 225Use of the -p option is insecure.
427c49bc
A
226.It
227Options:
228.Bl -tag -compact -width -indent-indent
229.It Fl P
230Prompt the user for a password using the SecurityAgent.
231.It Fl p Ar password
232Use
233.Ar password
234as the password for the keychains being created.
235.El
236.It
237If neither
238.Fl P
239or
240.Fl p Ar password
241are specified the user is prompted for a password.
242.El
243.It
244.Nm delete-keychain
245.Op Fl h
246.Op Ar keychain...
247.Bl -item -offset -indent
248Delete keychains and remove them from the search list.
249.El
250.It
251.Nm lock-keychain
252.Op Fl h
253.Op Fl a Ns | Ns Ar keychain
254.Bl -item -offset -indent
255Lock
256.Ar keychain Ns
257\&. Or the default is none is specified. If the
258.Fl a
259options is specified all keychains are locked.
260.El
261.It
262.Nm unlock-keychain
263.Op Fl hu
264.Op Fl p Ar password
265.Op Ar keychain
266.Bl -item -offset -indent
267Unlock
268.Ar keychain Ns
269\&. Or the default is none is specified.
270.El
271.It
272.Nm set-keychain-settings
273.Op Fl hlu
274.Op Fl t Ar timeout
275.Op Ar keychain
276.Bl -item -offset -indent
277Set settings for
278.Ar keychain Ns
279\&. Or the default is none is specified.
280.Bl -tag -compact -width -indent-indent
281.It Fl l
282Lock keychain when the system sleeps
283.It Fl u
284Lock keychain after certain period of time specified using
285.Fl t Ns
286\&.
287.It Fl t Ar timeout
288Automatically lock keychain after
289.Ar timeout
290seconds of inactivity.
291.El
292.El
293.It
294.Nm show-keychain-info
295.Op Fl h
296.Bl -item -offset -indent
297Show the settings for keychain.
298.El
299.It
300.Nm dump-keychain
301.Op Fl adhir
302.Bl -item -offset -indent
303Dump the contents of one or more keychains.
304.Bl -tag -compact -width -indent-indent
305.It Fl a
306Dump acl of items.
307.It Fl d
308Dump cleartext data of items.
309.It Fl i
310Interactive acl editing mode.
311.It Fl r
312Dump raw (possibly ciphertext) data of items.
313.El
314.El
315.It
316.Nm create-keypair
317.Op Fl h
318.Op Fl a Ar alg
319.Op Fl s Ar size
320.Op Fl f Ar from_date
321.Op Fl t Ar to_date
322.Op Fl v Ar days
323.Op Fl k Ar keychain
324.Op Fl n Ar name
325.Op Fl A Ns | Ns Fl T Ar app1:app2:...
326.Bl -item -offset -indent
822b670c 327Create an asymmetric keypair.
427c49bc
A
328.El
329.It
330.Nm add-internet-password
331.Op Fl h
332.Op Fl a Ar account_name
333.Op Fl d Ar security_domain
334.Op Fl p Ar path
335.Op Fl P Ar port
336.Op Fl r Ar protocol
337.Op Fl s Ar server_name
338.Op Fl t Ar authentication_type
339.Op Fl w Ar password_data
340.Op Ar keychain
341.Bl -item -offset -indent
342Add an internet password item.
343.El
344.It
345.Nm add-certificates
346.Op Fl h
347.Op Fl k Ar keychain
348.Ar file...
349.Bl -item -offset -indent
350Add certficates contained in the specified
351.Ar files
352to the default keychain. The files must contain one DER encoded X509 certificate each.
353.Bl -tag -compact -width -indent-indent
354.It Fl k Ar keychain
355Use
356.Ar keychain
357rather than the default keychain.
358.El
359.El
360.It
361.Nm find-internet-password
362.Op Fl gh
363.Op Fl a Ar account_name
364.Op Fl d Ar security_domain
365.Op Fl p Ar path
366.Op Fl P Ar port
367.Op Fl r Ar protocol
368.Op Fl s Ar server_name
369.Op Fl t Ar authentication_type
370.Op Ar keychain...
371.Bl -item -offset -indent
372Find an internet password item.
373.El
374.It
375.Nm find-certificate
376.Op Fl ahmp
377.Op Fl e Ar email_address
378.Op Ar keychain...
379.Bl -item -offset -indent
380Find a certificate item. If no
381.Ar keychain
382arguments are provided,
383.Nm
384will search the default search list.
385.It
386Options:
822b670c 387.Bl -tag -compact -width -indent
427c49bc
A
388.It Fl a
389Find all matching certificates, not just the first one.
390.It Fl g Ar dl Ns | Ns Ar cspdl
391Use the AppleDL (default) or AppleCspDL
392.It Fl e Ar email_address
393Match on "email_address" when searching.
394.It Fl m
395Show the email addresses in the certificate.
396.It Fl p
397Output certificate in pem form. The default is to dump the attributes and keychain the cert is in.
398.El
399.It
400.Sy Examples
401.Bl -tag -width -indent
402.Dl security> find-certificate -a -p > allcerts.pem
403Exports 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
405Exports all certificates from all keychains with the email address
406mb@foo.com into a pem file called certs.pem.
407.El
408.El
409.It
410.Nm create-db
411.Op Fl aho0
412.Op Fl g Ar dl Ns | Ns Ar cspdl
413.Op Fl m Ar mode
414.Op Ar name
415.Bl -item -offset -indent
416Create an db using the DL. If
417.Ar name
418isn't provided
419.Nm
420will prompt the user to type a name.
421.It
422Options:
423.Bl -tag -compact -width -indent-indent
424.It Fl a
425Turn off autocommit
426.It Fl g Ar dl Ns | Ns Ar cspdl
427Use the AppleDL (default) or AppleCspDL
428.It Fl m Ar mode
429Set the file permissions to
430.Ar mode Ns
431\&.
432.It Fl o
433Force using openparams argument
434.It Fl 0
435Force using version 0 openparams
436.El
437.It
438.Sy Examples
439.Bl -tag -width -indent
440.Dl security> create-db -m 0644 test.db
441.Dl security> create-db -g cspdl -a test2.db
442.El
443.\"new import/export commands.
444.El
445.It
446.Nm export
447.Op Fl k Ar keychain
448.Op Fl t Ar item_type
449.Op Fl f Ar item_format
450.Op Fl w
451.Op Fl p Ar item_format
452.Op Fl P Ar passphrase
453.Op Fl o Ar outfile
454.Bl -item -offset -indent
455Export one or more items from a keychain to one of a number of external representations. If
456.Ar keychain
457isn't provided, items will be exported from the user's default keychain.
458.It
459Options:
460.Bl -tag -compact -width -indent-indent
461.It Fl k Ar keychain
462Specify keychain from which item(s) will be exported.
463.It Fl t Ar item_type
464Specify 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
466Specify 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.
467.It Fl w
468Specifies that private keys are to be wrapped on export.
469.It Fl p
470Specifies that PEM armour is to be applied to the output data.
471.It Fl P Ar passphrase
472Specify the wrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
fa7225c8 473Use of the -P option is unsecure.
427c49bc
A
474.It Fl o Ar outfile
475Write the output data to
476.Ar outfile Ns
477\&. Default is to write data to stdout.
478.El
479.It
480.Sy Examples
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
484.El
485.\"marker.
486.El
487.It
488.Nm import
489inputfile
490.Op Fl k Ar keychain
491.Op Fl t Ar item_type
492.Op Fl f Ar item_format
493.Op Fl w
494.Op Fl P Ar passphrase
495.Bl -item -offset -indent
496Import one or more items from
497.Ar inputfile Ns
498\& into a keychain. If
499.Ar keychain
500isn't provided, items will be imported into the user's default keychain.
501.It
502Options:
503.Bl -tag -compact -width -indent-indent
504.It Fl k Ar keychain
505Specify keychain into which item(s) will be imported.
506.It Fl t Ar item_type
507Specify 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
509Specify 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.
510.It Fl w
511Specifies that private keys are wrapped and must be unwrapped on import.
512.It Fl P Ar passphrase
513Specify the unwrapping passphrase immediately. The default is to obtain a secure passphrase via GUI.
fa7225c8 514Use of the -P option is unsecure.
427c49bc
A
515.El
516.It
517.Sy Examples
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
522.El
523.\"end of new import/export commands.
524.It
525.Nm install-mds
526.Bl -item -offset -indent
527Install (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.
528.El
529.It
530.Nm leaks
531.Op Fl h
532.Op Fl cycles
533.Op Fl nocontext
534.Op Fl nostacks
535.Op Fl exclude Ar symbol
536.Bl -item -offset -indent
537Run
538.Li /usr/bin/leaks
539on this proccess. This is to help find memory leaks after running
540certain commands.
541.It
542Options:
543.Bl -tag -compact -width -indent-indent
544.It Fl cycles
545Use a stricter algorithm (See
546.Xr leaks 1
547for details).
548.It Fl nocontext
549Withhold the hex dumps of the leaked memory.
550.It Fl nostacks
551Don't show stack traces of leaked memory.
552.It Fl exclude Ar symbol
553Ignore leaks called from
554.Ar symbol Ns .
555.El
556.El
822b670c
A
557.It
558.Nm verify-cert
559.Op Fl c Ar certFile
560.Op Fl r Ar rootCertFile
561.Op Fl p Ar policy
866f8763 562.Op Fl C
822b670c
A
563.Op Fl d Ar date
564.Op Fl n Ar name
565.Op Fl L
566.Op Fl q
866f8763 567.Op Fl R Ar revCheckOption
822b670c
A
568.Bl -item -offset -indent
569Verify one or more certificates.
570.It
571Options:
572.Bl -tag -compact -width -indent-indent
573.It Fl c Ar certFile
574Certificate 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
576Root certificate, in DER or PEM format. Can be specified more than once. If not specified, the system anchor certificates are used.
577.It Fl p Ar policy
578Specify verification policy (ssl, smime, codeSign, IPSec, basic, eap, appleID, timestamping, revocation). Default is basic.
866f8763
A
579.It Fl C
580Specify this evaluation is for client usage, if the verification policy (e.g. ssl) distinguishes between client and server usage. Default is server usage.
822b670c
A
581.It Fl d Ar date
582Date 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
583.It Fl n Ar name
866f8763 584Specify a name to be verified, e.g. the SSL host name for the ssl policy, or RFC822 email address for the smime policy.
822b670c
A
585.It Fl L
586Use local certificates only. If an issuing CA certificate is missing, this option will avoid accessing the network to fetch it.
587.It Fl q
588Quiet, no stdout or stderr.
866f8763
A
589.It Fl R Ar revCheckOption
590Specify 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.
427c49bc 591.El
822b670c
A
592.It
593.Sy Examples
594.Bl -tag -width -indent
866f8763
A
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
427c49bc
A
597.El
598.Sh ENVIRONMENT \" May not be needed
599.Bl -tag -width -indent
600.It Ev MallocStackLogging
601When using the
602.Nm leaks
603command or the
604.Fl l
605option it's probably a good idea to set this environment variable before
606.Nm
607is started. Doing so will allow leaks to display symbolic backtraces.
608.El
609.Sh FILES
610.Bl -tag -width -indent
611.It Pa ~/Library/Preferences/com.apple.security.plist
612.Pp
613Propertylist file containing the current users default keychain and keychain search list.
614.It Pa /Library/Preferences/com.apple.security.plist
615.Pp
616Propertylist 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
618.Pp
619Propertylist file containing the a common keychain search list which is appended to every users searchlist and to the system search list as well.
620.El
621.Sh SEE ALSO
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
624.Xr certtool 1 ,
625.Xr leaks 1
626.\" .Xr systemkeychain 8
627.Sh HISTORY
628.Nm
629was first introduced in Mac OS X version 10.3
630.Sh AUTHORS
631.An "Michael Brouwer"
632.Sh BUGS
633.Nm
634still needs a lot more commands before it can be considered complete.
635In particular it should someday supersede both the
636.Li certtool
637and
638.Li systemkeychain
639commands.