summaryrefslogtreecommitdiffstats
path: root/pk12util.html
blob: 2398aa228205796c1bb04efbf86af62e46e72ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
Content-type: text/html

<HTML><HEAD><TITLE>Manpage of pk12util</TITLE>
</HEAD><BODY>
<H1>pk12util</H1>
Section: User Commands  (1)<BR>Updated: August 2010<BR><A HREF="#index">Index</A>
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>

<A NAME="lbAB">&nbsp;</A>
<H2>NAME </H2>

<BR>&nbsp;pk12util&nbsp;-&nbsp;Export&nbsp;and&nbsp;import&nbsp;keys&nbsp;and&nbsp;certificate&nbsp;to&nbsp;or&nbsp;from&nbsp;a&nbsp;PKCS&nbsp;#12&nbsp;file&nbsp;and&nbsp;the&nbsp;NSS&nbsp;database
<A NAME="lbAC">&nbsp;</A>
<H2>Synopsis </H2>

<B>pk12util </B>

-i p12File [-h tokenname] [-v] [common-options]  
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-l&nbsp;p12File&nbsp;[-h&nbsp;tokenname]&nbsp;[-r]&nbsp;[common-options]&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o&nbsp;p12File&nbsp;-n&nbsp;certname&nbsp;[-c&nbsp;keyCipher]&nbsp;[-C&nbsp;certCipher]&nbsp;[-m|--key_len&nbsp;keyLen]&nbsp;[-n|--cert_key_len&nbsp;certKeyLen]&nbsp;[common-options]&nbsp;&nbsp;
<BR>&nbsp;
<BR>&nbsp;common-options&nbsp;are:&nbsp;
<BR>&nbsp;[-d&nbsp;dir]&nbsp;[-P&nbsp;dbprefix]&nbsp;[-k&nbsp;slotPasswordFile|-K&nbsp;slotPassword]&nbsp;[-w&nbsp;p12filePasswordFile|-W&nbsp;p12filePassword]&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<A NAME="lbAD">&nbsp;</A>
<H2>Description </H2>

<P>
<P>

The PKCS #12 utility, 
<B>pk12util</B>

, enables sharing certificates among any server that supports PKCS#12. The tool can import certificates and keys from PKCS#12 files into security databases, export certificates, and list certificates and keys.
<A NAME="lbAE">&nbsp;</A>
<H2>Options and Arguments </H2>

<P>
<P>

<B>Options</B>

<P>
<DL COMPACT>
<DT><B>-i p12file</B>

<DD>
<P>
<DT><DD>
Import keys and certificates from a PKCS#12 file into a security database.
<P>
<DT><B>-l p12file</B>

<DD>
<P>
<DT><DD>
List the keys and certificates in PKCS#12 file.
<P>
<DT><B>-o p12file</B>

<DD>
<P>
<DT><DD>
Export keys and certificates from the security database to a PKCS#12 file.
<P>
</DL>
<P>

<B>Arguments</B>

<P>
<DL COMPACT>
<DT><B>-n certname</B>

<DD>
<P>
<DT><DD>
Specify the nickname of the cert and private key to export.
<P>
<DT><B>-d dir</B>

<DD>
<P>
<DT><DD>
Specify the database directory into which to import to or export from certificates and keys. 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;not&nbsp;specified&nbsp;the&nbsp;directory&nbsp;defaults&nbsp;to&nbsp;$HOME/.netscape&nbsp;(when&nbsp;$HOME&nbsp;exists&nbsp;in&nbsp;the&nbsp;environment),&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;to&nbsp;./.netscape&nbsp;(when&nbsp;$HOME&nbsp;does&nbsp;not&nbsp;exist&nbsp;in&nbsp;the&nbsp;environment.
<P>
<DT><B>-P prefix</B>

<DD>
<P>
<DT><DD>
Specify the prefix used on the cert8.db and key3.db files 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(for&nbsp;example,&nbsp;my_cert8.db&nbsp;and&nbsp;my_key3.db).&nbsp;This&nbsp;option&nbsp;is&nbsp;provided&nbsp;as&nbsp;a&nbsp;special&nbsp;case.&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Changing&nbsp;the&nbsp;names&nbsp;of&nbsp;the&nbsp;certificate&nbsp;and&nbsp;key&nbsp;databases&nbsp;is&nbsp;not&nbsp;recommended.
<P>
<DT><B>-h tokenname</B>

<DD>
<P>
<DT><DD>
Specify the name of the token to import into or export from.
<P>
<DT><B>-v </B>

<DD>
<P>
<DT><DD>
Enable debug logging when importing.
<P>
<DT><B>-k slotPasswordFile</B>

<DD>
<P>
<DT><DD>
Specify the text file containing the slot's password.
<P>
<DT><B>-K slotPassword</B>

<DD>
<P>
<DT><DD>
Specify the slot's password.
<P>
<DT><B>-w p12filePasswordFile</B>

<DD>
<P>
<DT><DD>
Specify the text file containing the pkcs #12 file password.
<P>
<DT><B>-W p12filePassword</B>

<DD>
<P>
<DT><DD>
Specify the pkcs #12 file password.
<P>
<DT><B>-c keyCipher</B>

<DD>
<P>
<DT><DD>
Specify the key encryption algorithm.
<P>
<DT><B>-C certCipher</B>

<DD>
<P>
<DT><DD>
Specify the key cert (overall package) encryption algorithm.
<P>
<DT><B>-m | --key-len  keyLength</B>

<DD>
<P>
<DT><DD>
Specify the desired length of the symmetric key to be used to encrypt the private key.
<P>
<DT><B>-n | --cert-key-len  certKeyLength</B>

<DD>
<P>
<DT><DD>
Specify the desired length of the symmetric key to be used to encrypt the certificates and other meta-data.
<P>
<DT><B>-r</B>

<DD>
<P>
<DT><DD>
Dumps all of the data in raw (binary) form. This must be saved as a DER file. The default is to return information in a pretty-print ASCII format, which displays the information about the certificates and public keys in the p12 file.
<P>
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>Return Codes </H2>

<P>
<P>

* 0 - No error
<P>

* 1 - User Cancelled
<P>

* 2 - Usage error
<P>

* 6 - NLS init error
<P>

* 8 - Certificate DB open error
<P>

* 9 - Key DB open error
<P>

* 10 - File initialization error
<P>

* 11 - Unicode conversion error
<P>

* 12 - Temporary file creation error
<P>

* 13 - PKCS11 get slot error
<P>

* 14 - PKCS12 decoder start error
<P>

* 15 - error read from import file
<P>

* 16 - pkcs12 decode error
<P>

* 17 - pkcs12 decoder verify error
<P>

* 18 - pkcs12 decoder validate bags error
<P>

* 19 - pkcs12 decoder import bags error
<P>

* 20 - key db conversion version 3 to version 2 error
<P>

* 21 - cert db conversion version 7 to version 5 error
<P>

* 22 - cert and key dbs patch error
<P>

* 23 - get default cert db error
<P>

* 24 - find cert by nickname error
<P>

* 25 - create export context error
<P>

* 26 - PKCS12 add password itegrity error
<P>

* 27 - cert and key Safes creation error
<P>

* 28 - PKCS12 add cert and key error
<P>

* 29 - PKCS12 encode error
<A NAME="lbAG">&nbsp;</A>
<H2>Examples </H2>

<P>
<P>

<B>Importing Keys and Certificates</B>

<P>
<P>

The most basic usage of 
<B>pk12util</B>

for importing a certificate or key is the PKCS#12 input file (
<B>-i</B>

) and some way to specify the security database being accessed (either 
<B>-d</B>

for a directory or 
<B>-h</B>

for a token).
<BR>&nbsp;&nbsp;&nbsp;&nbsp;
<PRE>
pk12util -i p12File [-h tokenname] [-v] [-d dir] [-P dbprefix] [-k slotPasswordFile|-K slotPassword] [-w p12filePasswordFile|-W p12filePassword]
</PRE>

<P>
<P>

For example:
<PRE>
# pk12util -i /tmp/cert-files/users.p12 -d /etc/pki/nssdb/

Enter a password which will be used to encrypt your keys.
The password should be at least 8 characters long,
and should contain at least one non-alphabetic character.

Enter new password: 
Re-enter password: 
Enter password for PKCS12 file: 
pk12util: PKCS12 IMPORT SUCCESSFUL
</PRE>

<P>
<P>

<B>Exporting Keys and Certificates</B>

<P>
<P>

Using the 
<B>pk12util</B>

command to export certificates and keys requires both the name of the certificate to extract from the database (
<B>-n</B>

) and the PKCS#12-formatted output file to write to. There are optional parameters that can be used to encrypt the file to protect the certificate material.
<BR>&nbsp;&nbsp;&nbsp;&nbsp;
<PRE>
pk12util -o p12File -n certname [-c keyCipher] [-C certCipher] [-m|--key_len keyLen] [-n|--cert_key_len certKeyLen] [-d dir] [-P dbprefix] [-k slotPasswordFile|-K slotPassword] [-w p12filePasswordFile|-W p12filePassword]
</PRE>

<P>
<P>

For example:
<PRE>
# pk12util -o certs.p12 -n Server-Cert -d /etc/pki/nssdb/
Enter password for PKCS12 file: 
Re-enter password: 
</PRE>

<P>
<P>

<B>Listing Keys and Certificates</B>

<P>
<P>

The information in a 
<B>.p12</B>

file are not human-readable. The certificates and keys in the file can be printed (listed) in a human-readable pretty-print format that shows information for every certificate and any public keys in the 
<B>.p12</B>

file. Alternatively, the 
<B>-r</B>

is used to print the certificates and then export them into separate DER binary files, with one certificate in each file. This allows the certificates to be fed to another application, like OpenSSL.
<BR>&nbsp;&nbsp;&nbsp;&nbsp;
<PRE>
pk12util -l p12File [-h tokenname] [-r] [-d dir] [-P dbprefix] [-k slotPasswordFile|-K slotPassword] [-w p12filePasswordFile|-W p12filePassword]
</PRE>

<P>
<P>

For example, this prints the default ASCII output:
<PRE>
# pk12util -l certs.p12

Enter password for PKCS12 file: 
Key(shrouded):
    Friendly Name: Thawte Freemail Member's Thawte Consulting (Pty) Ltd. ID

    Encryption algorithm: PKCS #12 V2 PBE With SHA-1 And 3KEY Triple DES-CBC
        Parameters:
            Salt:
                45:2e:6a:a0:03:4d:7b:a1:63:3c:15:ea:67:37:62:1f
            Iteration Count: 1 (0x1)
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 13 (0xd)
        Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption
        Issuer: &quot;E=<A HREF="mailto:personal-freemail@thawte.com">personal-freemail@thawte.com</A>,CN=Thawte Personal Freemail C
            A,OU=Certification Services Division,O=Thawte Consulting,L=Cape T
            own,ST=Western Cape,C=ZA&quot;
</PRE>

<P>
<P>

For example, this uses the 
<B>-r</B>

argument to output the DER information. Each certificate is also written to a sequentially-number file, beginning with 
<B>file0001.der</B>

and continuing through 
<B>file000N.der</B>

, incrementing the number for every certificate:
<PRE>
# pk12util -l test.p12 -r
Enter password for PKCS12 file: 
Key(shrouded):
    Friendly Name: Thawte Freemail Member's Thawte Consulting (Pty) Ltd. ID

    Encryption algorithm: PKCS #12 V2 PBE With SHA-1 And 3KEY Triple DES-CBC
        Parameters:
            Salt:
                45:2e:6a:a0:03:4d:7b:a1:63:3c:15:ea:67:37:62:1f
            Iteration Count: 1 (0x1)
Certificate    Friendly Name: Thawte Personal Freemail Issuing CA - Thawte Consulting

Certificate    Friendly Name: Thawte Freemail Member's Thawte Consulting (Pty) Ltd. ID
</PRE>

<P>
<A NAME="lbAH">&nbsp;</A>
<H2>Password Encryption </H2>

<P>
<P>

PKCS#12 provides for not only the protection of the private keys but also the certificate and meta-data associated with the keys. Password-based encryption is used to protect private keys on export to a PKCS#12 file and, optionally, the entire package. If no algorithm is specified, the tool defaults to using 
<B>PKCS12 V2 PBE with SHA1 and 3KEY Triple DES-cbc</B>

for private key encryption. 
<B>PKCS12 V2 PBE with SHA1 and 40 Bit RC4</B>

is the default for the overall package encryption when not in FIPS mode. When in FIPS mode, there is no package encryption.
<P>

The private key is always protected with strong encryption by default.
<P>

Several types of ciphers are supported.
<DL COMPACT>
<DT><B>Symmetric CBC ciphers for PKCS#5 V2</B>

<DD>
<P>
<DT><DD>
* DES_CBC
<DT><DD>
* RC2-CBC
<DT><DD>
* RC5-CBCPad
<DT><DD>
* DES-EDE3-CBC (the default for key encryption)
<DT><DD>
* AES-128-CBC
<DT><DD>
* AES-192-CBC
<DT><DD>
* AES-256-CBC
<DT><DD>
* CAMELLIA-128-CBC
<DT><DD>
* CAMELLIA-192-CBC
<DT><DD>
* CAMELLIA-256-CBC
<P>
<DT><B>PKCS#12 PBE ciphers</B>

<DD>
<P>
<DT><DD>
* PKCS #12 PBE with Sha1 and 128 Bit RC4
<DT><DD>
* PKCS #12 PBE with Sha1 and 40 Bit RC4
<DT><DD>
* PKCS #12 PBE with Sha1 and Triple DES CBC
<DT><DD>
* PKCS #12 PBE with Sha1 and 128 Bit RC2 CBC
<DT><DD>
* PKCS #12 PBE with Sha1 and 40 Bit RC2 CBC
<DT><DD>
* PKCS12 V2 PBE with SHA1 and 128 Bit RC4
<DT><DD>
* PKCS12 V2 PBE with SHA1 and 40 Bit RC4 (the default for non-FIPS mode)
<DT><DD>
* PKCS12 V2 PBE with SHA1 and 3KEY Triple DES-cbc
<DT><DD>
* PKCS12 V2 PBE with SHA1 and 2KEY Triple DES-cbc
<DT><DD>
* PKCS12 V2 PBE with SHA1 and 128 Bit RC2 CBC
<DT><DD>
* PKCS12 V2 PBE with SHA1 and 40 Bit RC2 CBC
<P>
<DT><B>PKCS#5 PBE ciphers</B>

<DD>
<P>
<DT><DD>
* PKCS #5 Password Based Encryption with MD2 and DES CBC
<DT><DD>
* PKCS #5 Password Based Encryption with MD5 and DES CBC
<DT><DD>
* PKCS #5 Password Based Encryption with SHA1 and DES CBC
<P>
</DL>
<P>

With PKCS#12, the crypto provider may be the soft token module or an external hardware module. If the cryptographic module does not support the requested algorithm, then the next best fit will be selected (usually the default). If no suitable replacement for the desired algorithm can be found, the tool returns the error 
<I>no security module can perform the requested operation</I>

<A NAME="lbAI">&nbsp;</A>
<H2>See Also </H2>

<P>
<P>

certutil (1)
<P>

modutil (1)
<A NAME="lbAJ">&nbsp;</A>
<H2>Additional Resources </H2>

<P>
<P>

NSS is maintained in conjunction with PKI and security-related projects through Mozilla dn Fedora. The most closely-related project is Dogtag PKI, with a project wiki at <A HREF="http://pki.fedoraproject.org/wiki/.">http://pki.fedoraproject.org/wiki/.</A> 
<P>

For information specifically about NSS, the NSS project wiki is located at <A HREF="http://www.mozilla.org/projects/security/pki/nss/.">http://www.mozilla.org/projects/security/pki/nss/.</A> The NSS site relates directly to NSS code changes and releases.
<P>

Mailing lists: <A HREF="mailto:pki-devel@redhat.com">pki-devel@redhat.com</A> and <A HREF="mailto:pki-users@redhat.com">pki-users@redhat.com</A>
<P>

IRC: Freenode at #dogtag-pki
<A NAME="lbAK">&nbsp;</A>
<H2>Authors </H2>

<P>
<P>

The NSS tools were written and maintained by developers with Netscape and now with Red Hat.
<P>

Authors: Elio Maldonado &lt;<A HREF="mailto:emaldona@redhat.com">emaldona@redhat.com</A>&gt;, Deon Lackey &lt;<A HREF="mailto:dlackey@redhat.com">dlackey@redhat.com</A>&gt;.
<TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TT><BR>
<A NAME="lbAL">&nbsp;</A>
<H2>Copyright </H2>

<P>
<P>

(c) 2010, Red Hat, Inc. Licensed under the GNU Public License version 2.
<P>

<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME </A><DD>
<DT><A HREF="#lbAC">Synopsis </A><DD>
<DT><A HREF="#lbAD">Description </A><DD>
<DT><A HREF="#lbAE">Options and Arguments </A><DD>
<DT><A HREF="#lbAF">Return Codes </A><DD>
<DT><A HREF="#lbAG">Examples </A><DD>
<DT><A HREF="#lbAH">Password Encryption </A><DD>
<DT><A HREF="#lbAI">See Also </A><DD>
<DT><A HREF="#lbAJ">Additional Resources </A><DD>
<DT><A HREF="#lbAK">Authors </A><DD>
<DT><A HREF="#lbAL">Copyright </A><DD>
</DL>
<HR>
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 23:21:04 GMT, August 20, 2010
</BODY>
</HTML>