1keytool(1) General Commands Manual keytool(1)
2
3
4
6 keytool - Key and Certificate Management Tool
7
8 Manages a keystore (database) of cryptographic keys, X.509 certifi‐
9 cate chains, and trusted certificates.
10
12 keytool [ commands ]
13
14
15 The keytool command interface has changed in Java SE 6. See the Changes
16 Section for a detailed description. Note that previously defined com‐
17 mands are still supported.
18
20 keytool is a key and certificate management utility. It allows users to
21 administer their own public/private key pairs and associated certifi‐
22 cates for use in self-authentication (where the user authenticates him‐
23 self/herself to other users/services) or data integrity and authentica‐
24 tion services, using digital signatures. It also allows users to cache
25 the public keys (in the form of certificates) of their communicating
26 peers.
27
28 A certificate is a digitally signed statement from one entity (person,
29 company, etc.), saying that the public key (and some other information)
30 of some other entity has a particular value. (See Certificates.) When
31 data is digitally signed, the signature can be verified to check the
32 data integrity and authenticity. Integrity means that the data has not
33 been modified or tampered with, and authenticity means the data indeed
34 comes from whoever claims to have created and signed it.
35
36 keytool also enables users to administer secret keys used in symmetric
37 encryption/decryption (e.g. DES).
38
39 keytool stores the keys and certificates in a keystore.
40
42 The various commands and their options are listed and described below .
43 Note:
44
45 o All command and option names are preceded by a minus sign (-).
46
47 o The options for each command may be provided in any order.
48
49 o All items not italicized or in braces or square brackets are
50 required to appear as is.
51
52 o Braces surrounding an option generally signify that a default
53 value will be used if the option is not specified on the command
54 line. Braces are also used around the -v, -rfc, and -J options,
55 which only have meaning if they appear on the command line (that
56 is, they don't have any "default" values other than not existing).
57
58 o Brackets surrounding an option signify that the user is prompted
59 for the value(s) if the option is not specified on the command
60 line. (For a -keypass option, if you do not specify the option on
61 the command line, keytool will first attempt to use the keystore
62 password to recover the private/secret key, and if this fails,
63 will then prompt you for the private/secret key password.)
64
65 o Items in italics (option values) represent the actual values that
66 must be supplied. For example, here is the format of the -print‐
67 cert command:
68 keytool -printcert {-file cert_file} {-v}
69
70 When specifying a -printcert command, replace cert_file with the
71 actual file name, as in:
72 keytool -printcert -file VScert.cer
73
74 o Option values must be quoted if they contain a blank (space).
75
76 o The -help command is the default. Thus, the command line
77 keytool
78 is equivalent to
79 keytool -help
80
81
82 Option Defaults
83 Below are the defaults for various option values.
84 -alias "mykey"
85
86 -keyalg
87 "DSA" (when using -genkeypair)
88 "DES" (when using -genseckey)
89
90 -keysize
91 1024 (when using -genkeypair)
92 56 (when using -genseckey and -keyalg is "DES")
93 168 (when using -genseckey and -keyalg is "DESede")
94
95 -validity 90
96
97 -keystore the file named .keystore in the user's home directory
98
99 -storetype the value of the "keystore.type" property in the security properties file,
100 which is returned by the static getDefaultType method in java.security.KeyStore
101
102 -file stdin if reading, stdout if writing
103
104 -protected false
105
106
107
108 In generating a public/private key pair, the signature algorithm
109 (-sigalg option) is derived from the algorithm of the underlying
110 private key: If the underlying private key is of type "DSA", the
111 -sigalg option defaults to "SHA1withDSA", and if the underlying pri‐
112 vate key is of type "RSA", -sigalg defaults to "MD5withRSA". Please
113 consult the Java Cryptography Architecture API Specification & Ref‐
114 erence @
115 http://java.sun.com/javase/6/docs/technotes/guides/secu‐
116 rity/crypto/CryptoSpec.html#AppA for a full list of -keyalg and
117 -sigalg you can choose from.
118
119 Common Options
120 The -v option can appear for all commands except -help. If it
121 appears, it signifies "verbose" mode; more information will be out‐
122 put.
123
124 There is also a -Jjavaoption option that may appear for any command.
125 If it appears, the specified javaoption string is passed through
126 directly to the Java interpreter. This option should not contain any
127 spaces. It is useful for adjusting the execution environment or mem‐
128 ory usage. For a list of possible interpreter options, type java -h
129 or java -X at the command line.
130
131 These options may appear for all commands operating on a keystore:
132
133 -storetype storetype
134 This qualifier specifies the type of keystore to be instanti‐
135 ated.
136
137 -keystore keystore
138 The keystore location.
139
140 If the JKS storetype is used and a keystore file does not yet
141 exist, then certain keytool commands may result in a new keystore
142 file being created. For example, if keytool -genkeypair is
143 invoked and the -keystore option is not specified, the default
144 keystore file named .keystore in the user's home directory will
145 be created if it does not already exist. Similarly, if the -key‐
146 store ks_file option is specified but ks_file does not exist,
147 then it will be created
148
149 Note that the input stream from the -keystore option is passed to
150 the KeyStore.load method. If NONE is specified as the URL, then a
151 null stream is passed to the KeyStore.load method. NONE should be
152 specified if the KeyStore is not file-based (for example, if it
153 resides on a hardware token device).
154
155 -storepass storepass
156 The password which is used to protect the integrity of the
157 keystore.
158
159 storepass must be at least 6 characters long. It must be provided
160 to all commands that access the keystore contents. For such com‐
161 mands, if a -storepass option is not provided at the command
162 line, the user is prompted for it.
163
164 When retrieving information from the keystore, the password is
165 optional; if no password is given, the integrity of the retrieved
166 information cannot be checked and a warning is displayed.
167
168 -providerName provider_name
169 Used to identify a cryptographic service provider's name when
170 listed in the security properties file.
171
172 -providerClass provider_class_name
173 Used to specify the name of cryptographic service provider's
174 master class file when the service provider is not listed in
175 the security properties file.
176
177 -providerArg provider_arg
178 Used in conjunction with -providerClass. Represents an
179 optional string input argument for the constructor of
180 provider_class_name.
181
182 -protected
183 Either true or false. This value should be specified as true
184 if a password must be given via a protected authentication
185 path such as a dedicated PIN reader.
186
187
189 Creating or Adding Data to the Keystore
190 -genkeypair {-alias alias} {-keyalg keyalg} {-keysize keysize}
191 {-sigalg sigalg} [-dname dname] [-keypass keypass] {-validity
192 valDays} {-storetype storetype} {-keystore keystore} [-storepass
193 storepass] {-providerClass provider_class_name {-providerArg
194 provider_arg}} {-v} {-protected} {-Jjavaoption}
195
196 Generates a key pair (a public key and associated private key).
197 Wraps the public key into an X.509 v3 self-signed certificate,
198 which is stored as a single-element certificate chain. This cer‐
199 tificate chain and the private key are stored in a new keystore
200 entry identified by alias.
201
202 keyalg specifies the algorithm to be used to generate the key
203 pair, and keysize specifies the size of each key to be generated.
204 sigalg specifies the algorithm that should be used to sign the
205 self-signed certificate; this algorithm must be compatible with
206 keyalg.
207
208 dname specifies the X.500 Distinguished Name to be associated
209 with alias, and is used as the issuer and subject fields in the
210 self-signed certificate. If no distinguished name is provided at
211 the command line, the user will be prompted for one.
212
213 keypass is a password used to protect the private key of the gen‐
214 erated key pair. If no password is provided, the user is prompted
215 for it. If you press RETURN at the prompt, the key password is
216 set to the same password as that used for the keystore. keypass
217 must be at least 6 characters long.
218
219 valDays tells the number of days for which the certificate should
220 be considered valid.
221
222 This command was named -genkey in previous releases. This old
223 name is still supported in this release and will be supported in
224 future releases, but for clarify the new name, -genkeypair, is
225 preferred going forward.
226
227 -genseckey {-alias alias} {-keyalg keyalg} {-keysize keysize}
228 [-keypass keypass] {-storetype storetype} {-keystore keystore}
229 [-storepass storepass] {-providerClass provider_class_name
230 {-providerArg provider_arg}} {-v} {-protected} {-Jjavaoption}
231
232 Generates a secret key and stores it in a new Key‐
233 Store.SecretKeyEntry identified by alias.
234
235 keyalg specifies the algorithm to be used to generate the secret
236 key, and keysize specifies the size of the key to be generated.
237 keypass is a password used to protect the secret key. If no pass‐
238 word is provided, the user is prompted for it. If you press
239 RETURN at the prompt, the key password is set to the same pass‐
240 word as that used for the keystore. keypass must be at least 6
241 characters long.
242
243 -importcert {-alias alias} {-file cert_file} [-keypass keypass]
244 {-noprompt} {-trustcacerts} {-storetype storetype} {-keystore
245 keystore} [-storepass storepass] {-providerName provider_name}
246 {-providerClass provider_class_name {-providerArg provider_arg}}
247 {-v} {-protected} {-Jjavaoption}
248
249 Reads the certificate or certificate chain (where the latter is
250 supplied in a PKCS#7 formatted reply) from the file cert_file,
251 and stores it in the keystore entry identified by alias. If no
252 file is given, the certificate or PKCS#7 reply is read from
253 stdin.
254
255 keytool can import X.509 v1, v2, and v3 certificates, and PKCS#7
256 formatted certificate chains consisting of certificates of that
257 type. The data to be imported must be provided either in binary
258 encoding format, or in printable encoding format (also known as
259 Base64 encoding) as defined by the Internet RFC 1421 standard. In
260 the latter case, the encoding must be bounded at the beginning by
261 a string that starts with "-----BEGIN", and bounded at the end by
262 a string that starts with "-----END".
263
264 You import a certificate for two reasons:
265
266 1. to add it to the list of trusted certificates, or
267
268 2. to import a certificate reply received from a CA as the
269 result of submitting a Certificate Signing Request (see the
270 -certreq command) to that CA.
271
272 Which type of import is intended is indicated by the value of the
273 -alias option:
274
275 1. If the alias does not point to a key entry, then keytool
276 assumes you are adding a trusted certificate entry. In this
277 case, the alias should not already exist in the keystore.
278 If the alias does already exist, then keytool outputs an
279 error, since there is already a trusted certificate for
280 that alias, and does not import the certificate.
281
282 2. If the alias points to a key entry, then keytool assumes
283 you are importing a certificate reply.
284 Importing a New Trusted Certificate
285
286
287 Before adding the certificate to the keystore, keytool tries
288 to verify it by attempting to construct a chain of trust from
289 that certificate to a self-signed certificate (belonging to a
290 root CA), using trusted certificates that are already avail‐
291 able in the keystore.
292
293 If the -trustcacerts option has been specified, additional
294 certificates are considered for the chain of trust, namely the
295 certificates in a file named "cacerts".
296
297 If keytool fails to establish a trust path from the certifi‐
298 cate to be imported up to a self-signed certificate (either
299 from the keystore or the "cacerts" file), the certificate
300 information is printed out, and the user is prompted to verify
301 it, e.g., by comparing the displayed certificate fingerprints
302 with the fingerprints obtained from some other (trusted)
303 source of information, which might be the certificate owner
304 himself/herself. Be very careful to ensure the certificate is
305 valid prior to importing it as a "trusted" certificate! -- see
306 WARNING Regarding Importing Trusted Certificates. The user
307 then has the option of aborting the import operation. If the
308 -noprompt option is given, however, there will be no interac‐
309 tion with the user.
310
311 Importing a Certificate Reply
312
313 When importing a certificate reply, the certificate reply is
314 validated using trusted certificates from the keystore, and
315 optionally using the certificates configured in the "cacerts"
316 keystore file (if the -trustcacerts option was specified).
317
318 The methods of determining whether the certificate reply is
319 trusted are described in the following:
320
321 o If the reply is a single X.509 certificate, keytool
322 attempts to establish a trust chain, starting at the cer‐
323 tificate reply and ending at a self-signed certificate
324 (belonging to a root CA). The certificate reply and the
325 hierarchy of certificates used to authenticate the cer‐
326 tificate reply form the new certificate chain of alias.
327 If a trust chain cannot be established, the certificate
328 reply is not imported. In this case, keytool does not
329 print out the certificate and prompt the user to verify
330 it, because it is very hard (if not impossible) for a
331 user to determine the authenticity of the certificate
332 reply.
333
334 o If the reply is a PKCS#7 formatted certificate chain, the
335 chain is first ordered (with the user certificate first
336 and the self-signed root CA certificate last), before
337 keytool attempts to match the root CA certificate pro‐
338 vided in the reply with any of the trusted certificates
339 in the keystore or the "cacerts" keystore file (if the
340 -trustcacerts option was specified). If no match can be
341 found, the information of the root CA certificate is
342 printed out, and the user is prompted to verify it, e.g.,
343 by comparing the displayed certificate fingerprints with
344 the fingerprints obtained from some other (trusted)
345 source of information, which might be the root CA itself.
346 The user then has the option of aborting the import oper‐
347 ation. If the -noprompt option is given, however, there
348 will be no interaction with the user.
349
350
351 If the public key in the certificate reply matches the user's
352 public key already stored with under alias, the old certifi‐
353 cate chain is replaced with the new certificate chain in the
354 reply. The old chain can only be replaced if a valid keypass,
355 the password used to protect the private key of the entry, is
356 supplied. If no password is provided, and the private key
357 password is different from the keystore password, the user is
358 prompted for it.
359
360 This command was named -import in previous releases. This old
361 name is still supported in this release and will be supported in
362 future releases, but for clarify the new name, -importcert, is
363 preferred going forward.
364
365 -importkeystore -srckeystore srckeystore -destkeystore destkey‐
366 store {-srcstoretype srcstoretype} {-deststoretype deststoretype}
367 [-srcstorepass srcstorepass] [-deststorepass deststorepass]
368 {-srcprotected} {-destprotected} {-srcalias srcalias {-destalias
369 destalias} [-srckeypass srckeypass] [-destkeypass destkeypass] }
370 {-noprompt} {-srcProviderName src_provider_name} {-destProvider‐
371 Name dest_provider_name} {-providerClass provider_class_name
372 {-providerArg provider_arg}} {-v} {-protected} {-Jjavaoption}
373
374 Imports a single entry or all entries from a source keystore to a
375 destination keystore.
376
377 When the srcalias option is provided, the command imports the
378 single entry identified by the alias to the destination keystore.
379 If a destination alias is not provided with destalias, then
380 srcalias is used as the destination alias. If the source entry is
381 protected by a password, srckeypass will be used to recover the
382 entry. If srckeypass is not provided, then keytool will attempt
383 to use srcstorepass to recover the entry. If srcstorepass is
384 either not provided or is incorrect, the user will be prompted
385 for a password. The destination entry will be protected using
386 destkeypass. If destkeypass is not provided, the destination
387 entry will be protected with the source entry password.
388
389 If the srcalias option is not provided, then all entries in the
390 source keystore are imported into the destination keystore. Each
391 destination entry will be stored under the alias from the source
392 entry. If the source entry is protected by a password, src‐
393 storepass will be used to recover the entry. If srcstorepass is
394 either not provided or is incorrect, the user will be prompted
395 for a password. If a source keystore entry type is not supported
396 in the destination keystore, or if an error occurs while storing
397 an entry into the destination keystore, the user will be prompted
398 whether to skip the entry and continue, or to quit. The destina‐
399 tion entry will be protected with the source entry password.
400
401 If the destination alias already exists in the destination key‐
402 store, the user is prompted to either overwrite the entry, or to
403 create a new entry under a different alias name.
404
405 Note that if -noprompt is provided, the user will not be prompted
406 for a new destination alias. Existing entries will automatically
407 be overwritten with the destination alias name. Finally, entries
408 that can not be imported are automatically skipped and a warning
409 is output.
410
411 Exporting Data
412 -certreq {-alias alias} {-sigalg sigalg} {-file certreq_file}
413 [-keypass keypass] {-storetype storetype} {-keystore keystore}
414 [-storepass storepass] {-providerName provider_name} {-provider‐
415 Class provider_class_name {-providerArg provider_arg}} {-v}
416 {-protected} {-Jjavaoption}
417
418 Generates a Certificate Signing Request (CSR), using the PKCS#10
419 format.
420
421 A CSR is intended to be sent to a certificate authority (CA). The
422 CA will authenticate the certificate requestor (usually off-line)
423 and will return a certificate or certificate chain, used to
424 replace the existing certificate chain (which initially consists
425 of a self-signed certificate) in the keystore.
426
427 The private key and X.500 Distinguished Name associated with
428 alias are used to create the PKCS#10 certificate request. In
429 order to access the private key, the appropriate password must be
430 provided, since private keys are protected in the keystore with a
431 password. If keypass is not provided at the command line, and is
432 different from the password used to protect the integrity of the
433 keystore, the user is prompted for it.
434
435 sigalg specifies the algorithm that should be used to sign the
436 CSR.
437
438 The CSR is stored in the file certreq_file. If no file is given,
439 the CSR is output to stdout.
440
441 Use the importcert command to import the response from the CA.
442
443 -exportcert {-alias alias} {-file cert_file} {-storetype store‐
444 type} {-keystore keystore} [-storepass storepass] {-providerName
445 provider_name} {-providerClass provider_class_name {-providerArg
446 provider_arg}} {-rfc} {-v} {-protected} {-Jjavaoption}
447
448 Reads (from the keystore) the certificate associated with alias,
449 and stores it in the file cert_file.
450
451 If no file is given, the certificate is output to stdout.
452
453 The certificate is by default output in binary encoding, but will
454 instead be output in the printable encoding format, as defined by
455 the Internet RFC 1421 standard, if the -rfc option is specified.
456
457 If alias refers to a trusted certificate, that certificate is
458 output. Otherwise, alias refers to a key entry with an associated
459 certificate chain. In that case, the first certificate in the
460 chain is returned. This certificate authenticates the public key
461 of the entity addressed by alias.
462
463 This command was named -export in previous releases. This old
464 name is still supported in this release and will be supported in
465 future releases, but for clarify the new name, -exportcert, is
466 preferred going forward.
467
468
469 Displaying Data
470 -list {-alias alias} {-storetype storetype} {-keystore keystore}
471 [-storepass storepass] {-providerName provider_name} {-provider‐
472 Class provider_class_name {-providerArg provider_arg}} {-v |
473 -rfc} {-protected} {-Jjavaoption}
474
475 Prints (to stdout) the contents of the keystore entry identified
476 by alias. If no alias is specified, the contents of the entire
477 keystore are printed.
478
479 This command by default prints the MD5 fingerprint of a certifi‐
480 cate. If the -v option is specified, the certificate is printed
481 in human-readable format, with additional information such as the
482 owner, issuer, serial number, and any extensions. If the -rfc
483 option is specified, certificate contents are printed using the
484 printable encoding format, as defined by the Internet RFC 1421
485 standard
486
487 You cannot specify both -v and -rfc.
488
489 -printcert {-file cert_file} {-v} {-Jjavaoption}
490
491 Internet RFC 1421 standard.
492
493 Note: This option can be used independently of a keystore.
494
495
496 Managing the Keystore
497 -storepasswd [-new new_storepass] {-storetype storetype} {-key‐
498 store keystore} [-storepass storepass] {-providerName
499 provider_name} {-providerClass provider_class_name {-providerArg
500 provider_arg}} {-v} {-Jjavaoption}
501
502 Changes the password used to protect the integrity of the key‐
503 store contents. The new password is new_storepass, which must be
504 at least 6 characters long.
505
506 -keypasswd {-alias alias} [-keypass old_keypass] [-new new_key‐
507 pass] {-storetype storetype} {-keystore keystore} [-storepass
508 storepass] {-providerName provider_name} {-providerClass
509 provider_class_name {-providerArg provider_arg}} {-v} {-Jjavaop‐
510 tion}
511
512 Changes the password under which the private/secret key identi‐
513 fied by alias is protected, from old_keypass to new_keypass,
514 which must be at least 6 characters long.
515
516 If the -keypass option is not provided at the command line, and
517 the key password is different from the keystore password, the
518 user is prompted for it.
519
520 If the -new option is not provided at the command line, the user
521 is prompted for it.
522
523 -delete [-alias alias] {-storetype storetype} {-keystore key‐
524 store} [-storepass storepass] {-providerName provider_name}
525 {-providerClass provider_class_name {-providerArg provider_arg}}
526 {-v} {-protected} {-Jjavaoption}
527
528 Deletes from the keystore the entry identified by alias. The user
529 is prompted for the alias, if no alias is provided at the command
530 line.
531
532 -changealias {-alias alias} [-destalias destalias] [-keypass key‐
533 pass] {-storetype storetype} {-keystore keystore} [-storepass
534 storepass] {-providerName provider_name} {-providerClass
535 provider_class_name {-providerArg provider_arg}} {-v} {-pro‐
536 tected} {-Jjavaoption}
537
538 Move an existing keystore entry from the specified alias to a new
539 alias, destalias. If no destination alias is provided, the com‐
540 mand will prompt for one. If the original entry is protected with
541 an entry password, the password can be supplied via the "-key‐
542 pass" option. If no key password is provided, the storepass (if
543 given) will be attempted first. If that attempt fails, the user
544 will be prompted for a password.
545
546
547 Getting Help
548 -help
549
550 Lists the basic commands and their options.
551
552
554 Suppose you want to create a keystore for managing your public/private
555 key pair and certificates from entities you trust.
556
557 Generating Your Key Pair
558 The first thing you need to do is create a keystore and generate the
559 key pair. You could use a command such as the following:
560
561 keytool -genkeypair -dname "cn=Mark Jones, ou=JavaSoft, o=Sun, c=US"
562 -alias business -keypass kpi135 -keystore /working/mykeystore
563 -storepass ab987c -validity 180
564
565
566 (Please note: This must be typed as a single line. Multiple lines
567 are used in the examples just for legibility purposes.)
568
569 This command creates the keystore named "mykeystore" in the "work‐
570 ing" directory (assuming it doesn't already exist), and assigns it
571 the password "ab987c". It generates a public/private key pair for
572 the entity whose "distinguished name" has a common name of "Mark
573 Jones", organizational unit of "JavaSoft", organization of "Sun" and
574 two-letter country code of "US". It uses the default "DSA" key gen‐
575 eration algorithm to create the keys, both 1024 bits long.
576
577 It creates a self-signed certificate (using the default "SHA1with‐
578 DSA" signature algorithm) that includes the public key and the dis‐
579 tinguished name information. This certificate will be valid for 180
580 days, and is associated with the private key in a keystore entry
581 referred to by the alias "business". The private key is assigned the
582 password "kpi135".
583
584 The command could be significantly shorter if option defaults were
585 accepted. As a matter of fact, no options are required; defaults are
586 used for unspecified options that have default values, and you are
587 prompted for any required values. Thus, you could simply have the
588 following:
589
590 keytool -genkeypair
591
592
593 In this case, a keystore entry with alias "mykey" is created, with a
594 newly-generated key pair and a certificate that is valid for 90
595 days. This entry is placed in the keystore named ".keystore" in your
596 home directory. (The keystore is created if it doesn't already
597 exist.) You will be prompted for the distinguished name information,
598 the keystore password, and the private key password.
599
600 The rest of the examples assume you executed the -genkeypair command
601 without options specified, and that you responded to the prompts
602 with values equal to those given in the first -genkeypair command,
603 above (a private key password of "kpi135", etc.)
604
605 Requesting a Signed Certificate from a Certification Authority
606 So far all we've got is a self-signed certificate. A certificate is
607 more likely to be trusted by others if it is signed by a Certifica‐
608 tion Authority (CA). To get such a signature, you first generate a
609 Certificate Signing Request (CSR), via the following:
610
611 keytool -certreq -file MarkJ.csr
612
613
614 This creates a CSR (for the entity identified by the default alias
615 "mykey") and puts the request in the file named "MarkJ.csr". Submit
616 this file to a CA, such as VeriSign, Inc. The CA will authenticate
617 you, the requestor (usually off-line), and then will return a cer‐
618 tificate, signed by them, authenticating your public key. (In some
619 cases, they will actually return a chain of certificates, each one
620 authenticating the public key of the signer of the previous certifi‐
621 cate in the chain.)
622
623 Importing a Certificate for the CA
624 You need to replace your self-signed certificate with a certificate
625 chain, where each certificate in the chain authenticates the public
626 key of the signer of the previous certificate in the chain, up to a
627 "root" CA.
628
629 Before you import the certificate reply from a CA, you need one or
630 more "trusted certificates" in your keystore or in the cacerts key‐
631 store file (which is described in importcert command):
632
633 o If the certificate reply is a certificate chain, you just need
634 the top certificate of the chain (that is, the "root" CA cer‐
635 tificate authenticating that CA's public key).
636
637 o If the certificate reply is a single certificate, you need a
638 certificate for the issuing CA (the one that signed it), and if
639 that certificate is not self-signed, you need a certificate for
640 its signer, and so on, up to a self-signed "root" CA certifi‐
641 cate.
642
643
644 The "cacerts" keystore file ships with five VeriSign root CA cer‐
645 tificates, so you probably won't need to import a VeriSign certifi‐
646 cate as a trusted certificate in your keystore. But if you request a
647 signed certificate from a different CA, and a certificate authenti‐
648 cating that CA's public key hasn't been added to "cacerts", you will
649 need to import a certificate from the CA as a "trusted certificate".
650
651 A certificate from a CA is usually either self-signed, or signed by
652 another CA (in which case you also need a certificate authenticating
653 that CA's public key). Suppose company ABC, Inc., is a CA, and you
654 obtain a file named "ABCCA.cer" that is purportedly a self-signed
655 certificate from ABC, authenticating that CA's public key.
656
657 Be very careful to ensure the certificate is valid prior to import‐
658 ing it as a "trusted" certificate! View it first (using the keytool
659 -printcert command, or the keytool -importcert command without the
660 -noprompt option), and make sure that the displayed certificate fin‐
661 gerprint(s) match the expected ones. You can call the person who
662 sent the certificate, and compare the fingerprint(s) that you see
663 with the ones that they show (or that a secure public key repository
664 shows). Only if the fingerprints are equal is it guaranteed that the
665 certificate has not been replaced in transit with somebody else's
666 (for example, an attacker's) certificate. If such an attack took
667 place, and you did not check the certificate before you imported it,
668 you would end up trusting anything the attacker has signed.
669
670 If you trust that the certificate is valid, then you can add it to
671 your keystore via the following:
672
673 keytool -importcert -alias abc -file ABCCA.cer
674
675
676 This creates a "trusted certificate" entry in the keystore, with the
677 data from the file "ABCCA.cer", and assigns the alias "abc" to the
678 entry.
679
680 Importing the Certificate Reply from the CA
681 Once you've imported a certificate authenticating the public key of
682 the CA you submitted your certificate signing request to (or there's
683 already such a certificate in the "cacerts" file), you can import
684 the certificate reply and thereby replace your self-signed certifi‐
685 cate with a certificate chain. This chain is the one returned by the
686 CA in response to your request (if the CA reply is a chain), or one
687 constructed (if the CA reply is a single certificate) using the cer‐
688 tificate reply and trusted certificates that are already available
689 in the keystore where you import the reply or in the "cacerts" key‐
690 store file.
691
692 For example, suppose you sent your certificate signing request to
693 VeriSign. You can then import the reply via the following, which
694 assumes the returned certificate is named "VSMarkJ.cer":
695
696 keytool -importcert -trustcacerts -file VSMarkJ.cer
697
698
699 Exporting a Certificate Authenticating Your Public Key
700 Suppose you have used the jarsigner @
701 http://java.sun.com/javase/6/docs/tooldocs/solaris/jarsigner.html
702 tool to sign a Java ARchive (JAR) file. Clients that want to use the
703 file will want to authenticate your signature.
704
705 One way they can do this is by first importing your public key cer‐
706 tificate into their keystore as a "trusted" entry. You can export
707 the certificate and supply it to your clients. As an example, you
708 can copy your certificate to a file named MJ.cer via the following,
709 assuming the entry is aliased by "mykey":
710
711 keytool -exportcert -alias mykey -file MJ.cer
712
713
714 Given that certificate, and the signed JAR file, a client can use
715 the jarsigner tool to authenticate your signature.
716
717 Importing Keystore
718 The command "importkeystore" is used to import an entire keystore
719 into another keystore, which means all entries from the source key‐
720 store, including keys and certificates, are all imported to the des‐
721 tination keystore within a single command. You can use this command
722 to import entries from a different type of keystore. During the
723 import, all new entries in the destination keystore will have the
724 same alias names and protection passwords (for secret keys and pri‐
725 vate keys). If keytool has difficulties recover the private keys or
726 secret keys from the source keystore, it will prompt you for a pass‐
727 word. If it detects alias duplication, it will ask you for a new
728 one, you can specify a new alias or simply allow keytool to over‐
729 write the existing one.
730
731 For example, to import entries from a normal JKS type keystore
732 key.jks into a PKCS #11 type hardware based keystore, you can use
733 the command:
734
735 keytool -importkeystore
736 -srckeystore key.jks -destkeystore NONE
737 -srcstoretype JKS -deststoretype PKCS11
738 -srcstorepass changeit -deststorepass topsecret
739
740
741 The importkeystore command can also be used to import a single entry
742 from a source keystore to a destination keystore. In this case,
743 besides the options you see in the above example, you need to spec‐
744 ify the alias you want to import. With the srcalias option given,
745 you can also specify the desination alias name in the command line,
746 as well as protection password for a secret/private key and the des‐
747 tination protection password you want. In this way, you can issue a
748 keytool command that will never ask you a question. This makes it
749 very convenient to include a keytool command into a script file,
750 like this:
751
752 keytool -importkeystore
753 -srckeystore key.jks -destkeystore NONE
754 -srcstoretype JKS -deststoretype PKCS11
755 -srcstorepass changeit -deststorepass topsecret
756 -srcalias myprivatekey -destalias myoldprivatekey
757 -srckeypass oldkeypass -destkeypass mynewkeypass
758 -noprompt
759
760
762 KeyStore
763 A keystore is a storage facility for cryptographic keys and certifi‐
764 cates.
765
766 o
767
768 o KeyStore Entries
769
770
771 Keystores may have different types of entries. The two most
772 applicable entry types for keytool include:
773
774 1. key entries - each holds very sensitive cryptographic key
775 information, which is stored in a protected format to pre‐
776 vent unauthorized access. Typically, a key stored in this
777 type of entry is a secret key, or a private key accompanied
778 by the certificate "chain" for the corresponding public
779 key. The keytool can handle both types od entry, while jar‐
780 signer tool only handle the latter type of entry, that is
781 private keys and their associated certificate chains.
782
783 2. trusted certificate entries - each contains a single public
784 key certificate belonging to another party. It is called a
785 "trusted certificate" because the keystore owner trusts
786 that the public key in the certificate indeed belongs to
787 the identity identified by the "subject" (owner) of the
788 certificate. The issuer of the certificate vouches for
789 this, by signing the certificate.
790
791
792 o KeyStore Aliases
793
794 All keystore entries (key and trusted certificate entries) are
795 accessed via unique aliases.
796
797 An alias is specified when you add an entity to the keystore
798 using the -genseckey command to generate a secret key, -genkey‐
799 pair command to generate a key pair (public and private key) or
800 the -importcert command to add a certificate or certificate chain
801 to the list of trusted certificates. Subsequent keytool commands
802 must use this same alias to refer to the entity.
803
804 For example, suppose you use the alias duke to generate a new
805 public/private key pair and wrap the public key into a
806 self-signed certificate (see Certificate Chains) via the follow‐
807 ing command:
808
809 keytool -genkeypair -alias duke -keypass dukekeypasswd
810
811
812 This specifies an inital password of "dukekeypasswd" required by
813 subsequent commands to access the private key assocated with the
814 alias duke. If you later want to change duke's private key pass‐
815 word, you use a command like the following:
816 keytool -keypasswd -alias duke -keypass dukekeypasswd -new newpass
817
818
819 This changes the password from "dukekeypasswd" to "newpass".
820
821 Please note: A password should not actually be specified on a
822 command line or in a script unless it is for testing purposes, or
823 you are on a secure system. If you don't specify a required pass‐
824 word option on a command line, you will be prompted for it.
825
826 o KeyStore Implementation
827 The KeyStore class provided in the java.security package supplies
828 well-defined interfaces to access and modify the information in a
829 keystore. It is possible for there to be multiple different con‐
830 crete implementations, where each implementation is that for a
831 particular type of keystore.
832
833 Currently, two command-line tools (keytool and jarsigner) and a
834 GUI-based tool named Policy Tool make use of keystore implementa‐
835 tions. Since KeyStore is publicly available, users can write
836 additional security applications that use it.
837
838 There is a built-in default implementation, provided by Sun
839 Microsystems. It implements the keystore as a file, utilizing a
840 proprietary keystore type (format) named "JKS". It protects each
841 private key with its individual password, and also protects the
842 integrity of the entire keystore with a (possibly different)
843 password.
844
845 Keystore implementations are provider-based. More specifically,
846 the application interfaces supplied by KeyStore are implemented
847 in terms of a "Service Provider Interface" (SPI). That is, there
848 is a corresponding abstract KeystoreSpi class, also in the
849 java.security package, which defines the Service Provider Inter‐
850 face methods that "providers" must implement. (The term
851 "provider" refers to a package or a set of packages that supply a
852 concrete implementation of a subset of services that can be
853 accessed by the Java Security API.) Thus, to provide a keystore
854 implementation, clients must implement a "provider" and supply a
855 KeystoreSpi subclass implementation, as described in How to
856 Implement a Provider for the Java Cryptography Architecture.
857
858 Applications can choose different types of keystore implementa‐
859 tions from different providers, using the "getInstance" factory
860 method supplied in the KeyStore class. A keystore type defines
861 the storage and data format of the keystore information, and the
862 algorithms used to protect private/secret keys in the keystore
863 and the integrity of the keystore itself. Keystore implementa‐
864 tions of different types are not compatible.
865
866 keytool works on any file-based keystore implementation. (It
867 treats the keytore location that is passed to it at the command
868 line as a filename and converts it to a FileInputStream, from
869 which it loads the keystore information.) The jarsigner and poli‐
870 cytool tools, on the other hand, can read a keystore from any
871 location that can be specified using a URL.
872
873 For keytool and jarsigner, you can specify a keystore type at the
874 command line, via the -storetype option. For Policy Tool, you can
875 specify a keystore type via the "Keystore" menu.
876
877 If you don't explicitly specify a keystore type, the tools choose
878 a keystore implementation based simply on the value of the key‐
879 store.type property specified in the security properties file.
880 The security properties file is called java.security, and it
881 resides in the security properties directory, java.home/lib/secu‐
882 rity, where java.home is the runtime environment's directory (the
883 jre directory in the SDK or the top-level directory of the Java 2
884 Runtime Environment).
885
886 Each tool gets the keystore.type value and then examines all the
887 currently-installed providers until it finds one that implements
888 keystores of that type. It then uses the keystore implementation
889 from that provider.
890
891 The KeyStore class defines a static method named getDefaultType
892 that lets applications and applets retrieve the value of the key‐
893 store.type property. The following line of code creates an
894 instance of the default keystore type (as specified in the key‐
895 store.type property):
896
897 KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
898
899
900 The default keystore type is "jks" (the proprietary type of the
901 keystore implementation provided by Sun). This is specified by
902 the following line in the security properties file:
903
904 keystore.type=jks
905
906
907 To have the tools utilize a keystore implementation other than
908 the default, you can change that line to specify a different key‐
909 store type.
910
911 For example, if you have a provider package that supplies a key‐
912 store implementation for a keystore type called "pkcs12", change
913 the line to
914
915 keystore.type=pkcs12
916
917
918 Note: case doesn't matter in keystore type designations. For
919 example, "JKS" would be considered the same as "jks".
920
921 Certificate
922 A certificate (also known as a public-key certificate) is a digi‐
923 tally signed statement from one entity (the issuer), saying that the
924 public key (and some other information) of another entity (the sub‐
925 ject) has some specific value.
926
927 o
928
929 o Certificate Terms
930
931
932 Public Keys
933 These are numbers associated with a particular entity, and
934 are intended to be known to everyone who needs to have
935 trusted interactions with that entity. Public keys are used
936 to verify signatures.
937
938 Digitally Signed
939 If some data is digitally signed it has been stored with
940 the "identity" of an entity, and a signature that proves
941 that entity knows about the data. The data is rendered
942 unforgeable by signing with the entity's private key.
943
944 Identity
945 A known way of addressing an entity. In some systems the
946 identity is the public key, in others it can be anything
947 from a Unix UID to an Email address to an X.509 Distin‐
948 guished Name.
949
950 Signature
951 A signature is computed over some data using the private
952 key of an entity (the signer, which in the case of a cer‐
953 tificate is also known as the issuer).
954
955 Private Keys
956 These are numbers, each of which is supposed to be known
957 only to the particular entity whose private key it is (that
958 is, it's supposed to be kept secret). Private and public
959 keys exist in pairs in all public key cryptography systems
960 (also referred to as "public key crypto systems"). In a
961 typical public key crypto system, such as DSA, a private
962 key corresponds to exactly one public key. Private keys are
963 used to compute signatures.
964
965 Entity
966 An entity is a person, organization, program, computer,
967 business, bank, or something else you are trusting to some
968 degree.
969
970
971 Basically, public key cryptography requires access to users' pub‐
972 lic keys. In a large-scale networked environment it is impossible
973 to guarantee that prior relationships between communicating enti‐
974 ties have been established or that a trusted repository exists
975 with all used public keys. Certificates were invented as a solu‐
976 tion to this public key distribution problem. Now a Certification
977 Authority (CA) can act as a trusted third party. CAs are entities
978 (for example, businesses) that are trusted to sign (issue) cer‐
979 tificates for other entities. It is assumed that CAs will only
980 create valid and reliable certificates, as they are bound by
981 legal agreements. There are many public Certification Authori‐
982 ties, such as VeriSign @
983 http://www.verisign.com/, Thawte @
984 http://www.thawte.com/, Entrust @
985 http://www.entrust.com/, and so on. You can also run your own
986 Certification Authority using products such as the Netscape/Mi‐
987 crosoft Certificate Servers or the Entrust CA product for your
988 organization.
989
990 Using keytool, it is possible to display, import, and export cer‐
991 tificates. It is also possible to generate self-signed certifi‐
992 cates.
993
994 keytool currently handles X.509 certificates.
995
996 o X.509 Certificates
997 The X.509 standard defines what information can go into a cer‐
998 tificate, and describes how to write it down (the data format).
999 All the data in a certificate is encoded using two related stan‐
1000 dards called ASN.1/DER. Abstract Syntax Notation 1 describes
1001 data. The Definite Encoding Rules describe a single way to store
1002 and transfer that data.
1003
1004 All X.509 certificates have the following data, in addition to
1005 the signature:
1006
1007 Version
1008 This identifies which version of the X.509 standard applies
1009 to this certificate, which affects what information can be
1010 specified in it. Thus far, three versions are defined. key‐
1011 tool can import and export v1, v2, and v3 certificates. It
1012 generates v3 certificates.
1013
1014 X.509 Version 1 has been available since 1988, is widely
1015 deployed, and is the most generic.
1016
1017 X.509 Version 2 introduced the concept of subject and issuer
1018 unique identifiers to handle the possibility of reuse of sub‐
1019 ject and/or issuer names over time. Most certificate profile
1020 documents strongly recommend that names not be reused, and
1021 that certificates should not make use of unique identifiers.
1022 Version 2 certificates are not widely used.
1023
1024 X.509 Version 3 is the most recent (1996) and supports the
1025 notion of extensions, whereby anyone can define an extension
1026 and include it in the certificate. Some common extensions in
1027 use today are: KeyUsage (limits the use of the keys to partic‐
1028 ular purposes such as "signing-only") and AlternativeNames
1029 (allows other identities to also be associated with this pub‐
1030 lic key, e.g. DNS names, Email addresses, IP addresses).
1031 Extensions can be marked critical to indicate that the exten‐
1032 sion should be checked and enforced/used. For example, if a
1033 certificate has the KeyUsage extension marked critical and set
1034 to "keyCertSign" then if this certificate is presented during
1035 SSL communication, it should be rejected, as the certificate
1036 extension indicates that the associated private key should
1037 only be used for signing certificates and not for SSL use.
1038
1039 Serial Number
1040 The entity that created the certificate is responsible for
1041 assigning it a serial number to distinguish it from other
1042 certificates it issues. This information is used in numer‐
1043 ous ways, for example when a certificate is revoked its
1044 serial number is placed in a Certificate Revocation List
1045 (CRL).
1046
1047 Signature Algorithm Identifier
1048 This identifies the algorithm used by the CA to sign the
1049 certificate.
1050
1051 Issuer Name
1052 The X.500 Distinguished Name of the entity that signed the
1053 certificate. This is normally a CA. Using this certificate
1054 implies trusting the entity that signed this certificate.
1055 (Note that in some cases, such as root or top-level CA cer‐
1056 tificates, the issuer signs its own certificate.)
1057
1058 Validity Period
1059 Each certificate is valid only for a limited amount of
1060 time. This period is described by a start date and time and
1061 an end date and time, and can be as short as a few seconds
1062 or almost as long as a century. The validity period chosen
1063 depends on a number of factors, such as the strength of the
1064 private key used to sign the certificate or the amount one
1065 is willing to pay for a certificate. This is the expected
1066 period that entities can rely on the public value, if the
1067 associated private key has not been compromised.
1068
1069 Subject Name
1070 The name of the entity whose public key the certificate
1071 identifies. This name uses the X.500 standard, so it is
1072 intended to be unique across the Internet. This is the
1073 X.500 Distinguished Name (DN) of the entity, for example,
1074 CN=Java Duke, OU=Java Software Division, O=Sun Microsystems Inc, C=US
1075 (These refer to the subject's Common Name, Organizational
1076 Unit, Organization, and Country.)
1077
1078 Subject Public Key Information
1079 This is the public key of the entity being named, together
1080 with an algorithm identifier which specifies which public
1081 key crypto system this key belongs to and any associated
1082 key parameters.
1083
1084
1085 o Certificate Chains
1086
1087 keytool can create and manage keystore "key" entries that each
1088 contain a private key and an associated certificate "chain". The
1089 first certificate in the chain contains the public key corre‐
1090 sponding to the private key.
1091
1092 When keys are first generated (see the -genkeypair command), the
1093 chain starts off containing a single element, a self-signed cer‐
1094 tificate. A self-signed certificate is one for which the issuer
1095 (signer) is the same as the subject (the entity whose public key
1096 is being authenticated by the certificate). Whenever the -genkey‐
1097 pair command is called to generate a new public/private key pair,
1098 it also wraps the public key into a self-signed certificate.
1099
1100 Later, after a Certificate Signing Request (CSR) has been gener‐
1101 ated (see the -certreq command) and sent to a Certification
1102 Authority (CA), the response from the CA is imported (see
1103 -importcert), and the self-signed certificate is replaced by a
1104 chain of certificates. At the bottom of the chain is the certifi‐
1105 cate (reply) issued by the CA authenticating the subject's public
1106 key. The next certificate in the chain is one that authenticates
1107 the CA's public key.
1108
1109 In many cases, this is a self-signed certificate (that is, a cer‐
1110 tificate from the CA authenticating its own public key) and the
1111 last certificate in the chain. In other cases, the CA may return
1112 a chain of certificates. In this case, the bottom certificate in
1113 the chain is the same (a certificate signed by the CA, authenti‐
1114 cating the public key of the key entry), but the second certifi‐
1115 cate in the chain is a certificate signed by a different CA,
1116 authenticating the public key of the CA you sent the CSR to.
1117 Then, the next certificate in the chain will be a certificate
1118 authenticating the second CA's key, and so on, until a
1119 self-signed "root" certificate is reached. Each certificate in
1120 the chain (after the first) thus authenticates the public key of
1121 the signer of the previous certificate in the chain.
1122
1123 Many CAs only return the issued certificate, with no supporting
1124 chain, especially when there is a flat hierarchy (no intermedi‐
1125 ates CAs). In this case, the certificate chain must be estab‐
1126 lished from trusted certificate information already stored in the
1127 keystore.
1128
1129 A different reply format (defined by the PKCS#7 standard) also
1130 includes the supporting certificate chain, in addition to the
1131 issued certificate. Both reply formats can be handled by keytool.
1132
1133 The top-level (root) CA certificate is self-signed. However, the
1134 trust into the root's public key does not come from the root cer‐
1135 tificate itself (anybody could generate a self-signed certificate
1136 with the distinguished name of say, the VeriSign root CA!), but
1137 from other sources like a newspaper. The root CA public key is
1138 widely known. The only reason it is stored in a certificate is
1139 because this is the format understood by most tools, so the cer‐
1140 tificate in this case is only used as a "vehicle" to transport
1141 the root CA's public key. Before you add the root CA certificate
1142 to your keystore, you should view it (using the -printcert
1143 option) and compare the displayed fingerprint with the well-known
1144 fingerprint (obtained from a newspaper, the root CA's webpage,
1145 etc.).
1146
1147 o The cacerts Certificates File
1148
1149 A certificates file named "cacerts" resides in the security prop‐
1150 erties directory, java.home/lib/security, where java.home is the
1151 runtime environment's directory (the jre directory in the SDK or
1152 the top-level directory of the Java 2 Runtime Environment).
1153
1154 The "cacerts" file represents a system-wide keystore with CA cer‐
1155 tificates. System administrators can configure and manage that
1156 file using keytool, specifying "jks" as the keystore type. The
1157 "cacerts" keystore file ships with several root CA certificates
1158 with the following aliases and X.500 owner distinguished names:
1159
1160 * Alias: thawtepersonalfreemailca
1161 Owner DN: EmailAddress=personal-freemail@thawte.com,
1162 CN=Thawte Personal Freemail CA,
1163 OU=Certification Services Division,
1164 O=Thawte Consulting, L=Cape Town, ST=Western Cape, C=ZA
1165
1166 * Alias: thawtepersonalbasicca
1167 Owner DN: EmailAddress=personal-basic@thawte.com,
1168 CN=Thawte Personal Basic CA,
1169 OU=Certification Services Division,
1170 O=Thawte Consulting, L=Cape Town, ST=Western Cape, C=ZA
1171
1172 * Alias: thawtepersonalpremiumca
1173 Owner DN: EmailAddress=personal-premium@thawte.com,
1174 CN=Thawte Personal Premium CA,
1175 OU=Certification Services Division,
1176 O=Thawte Consulting, L=Cape Town, ST=Western Cape, C=ZA
1177
1178 * Alias: thawteserverca
1179 Owner DN: EmailAddress=server-certs@thawte.com,
1180 CN=Thawte Server CA, OU=Certification Services Division,
1181 O=Thawte Consulting cc, L=Cape Town, ST=Western Cape, C=ZA
1182
1183 * Alias: thawtepremiumserverca
1184 Owner DN: EmailAddress=premium-server@thawte.com,
1185 CN=Thawte Premium Server CA,
1186 OU=Certification Services Division,
1187 O=Thawte Consulting cc, L=Cape Town, ST=Western Cape, C=ZA
1188
1189 * Alias: verisignclass1ca
1190 Owner DN: OU=Class 1 Public Primary Certification Authority,
1191 O="VeriSign, Inc.", C=US
1192
1193 * Alias: verisignclass2ca
1194 Owner DN: OU=Class 2 Public Primary Certification Authority,
1195 O="VeriSign, Inc.", C=US
1196
1197 * Alias: verisignclass3ca
1198 Owner DN: OU=Class 3 Public Primary Certification Authority,
1199 O="VeriSign, Inc.", C=US
1200
1201 * Alias: verisignserverca
1202 Owner DN: OU=Secure Server Certification Authority,
1203 O="RSA Data Security, Inc.", C=US
1204
1205 * Alias: verisignclass1g2ca
1206 Owner DN: OU=VeriSign Trust Network,
1207 OU="(c) 1998 VeriSign, Inc. - For authorized use only",
1208 OU=Class 1 Public Primary Certification Authority - G2,
1209 O="VeriSign, Inc.", C=US
1210
1211 * Alias: verisignclass1g3ca
1212 Owner DN: CN=VeriSign Class 1 Public Primary Certification
1213 Authority - G3, OU="(c) 1999 VeriSign, Inc. - For authorized
1214 use only",
1215 OU=VeriSign Trust Network,
1216 O="VeriSign, Inc.", C=US
1217
1218 * Alias: verisignclass2g2ca
1219 Owner DN: OU=VeriSign Trust Network,
1220 OU="(c) 1998 VeriSign, Inc. - For authorized use only",
1221 OU=Class 2 Public Primary Certification Authority - G2,
1222 O="VeriSign, Inc.", C=US
1223
1224 * Alias: verisignclass2g3ca
1225 Owner DN: CN=VeriSign Class 2 Public Primary Certification
1226 Authority - G3,
1227 OU="(c) 1999 VeriSign, Inc. - For authorized use only",
1228 OU=VeriSign Trust Network,
1229 O="VeriSign, Inc.", C=US
1230
1231 * Alias: verisignclass3g2ca
1232 Owner DN: OU=VeriSign Trust Network,
1233 OU="(c) 1998 VeriSign, Inc. - For authorized use only",
1234 OU=Class 3 Public Primary Certification Authority - G2,
1235 O="VeriSign, Inc.", C=US
1236
1237 * Alias: verisignclass3g3ca
1238 Owner DN: CN=VeriSign Class 3 Public Primary Certification
1239 Authority - G3,
1240 OU="(c) 1999 VeriSign, Inc. - For authorized use only",
1241 OU=VeriSign Trust Network,
1242 O="VeriSign, Inc.", C=US
1243
1244 * Alias: baltimorecodesigningca
1245 Owner DN: CN=Baltimore CyberTrust Code Signing Root,
1246 OU=CyberTrust, O=Baltimore, C=IE
1247
1248 * Alias: gtecybertrustglobalca
1249 Owner DN: CN=GTE CyberTrust Global Root,
1250 OU="GTE CyberTrust Solutions, Inc.", O=GTE Corporation, C=US
1251
1252 * Alias: baltimorecybertrustca
1253 Owner DN: CN=Baltimore CyberTrust Root,
1254 OU=CyberTrust, O=Baltimore, C=IE
1255
1256 * Alias: gtecybertrustca
1257 Owner DN: CN=GTE CyberTrust Root,
1258 O=GTE Corporation, C=US
1259
1260 * Alias: gtecybertrust5ca
1261 Owner DN: CN=GTE CyberTrust Root 5,
1262 OU="GTE CyberTrust Solutions, Inc.", O=GTE Corporation, C=US
1263
1264 * Alias: entrustclientca
1265 Owner DN: CN=Entrust.net Client Certification Authority,
1266 OU=(c) 1999 Entrust.net Limited,
1267 OU=www.entrust.net/Client_CA_Info/CPS incorp. by ref. limits
1268 liab.,
1269 O=Entrust.net, C=US
1270
1271 * Alias: entrustglobalclientca
1272 Owner DN: CN=Entrust.net Client Certification Authority,
1273 OU=(c) 2000 Entrust.net Limited,
1274 OU=www.entrust.net/GCCA_CPS incorp. by ref. (limits liab.),
1275 O=Entrust.net
1276
1277 * Alias: entrust2048ca
1278 Owner DN: CN=Entrust.net Certification Authority (2048),
1279 OU=(c) 1999 Entrust.net Limited,
1280 OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),
1281 O=Entrust.net
1282
1283 * Alias: entrustsslca
1284 Owner DN: CN=Entrust.net Secure Server Certification Author‐
1285 ity,
1286 OU=(c) 1999 Entrust.net Limited,
1287 OU=www.entrust.net/CPS incorp. by ref. (limits liab.),
1288 O=Entrust.net, C=US
1289
1290 * Alias: entrustgsslca
1291 Owner DN: CN=Entrust.net Secure Server Certification Author‐
1292 ity,
1293 OU=(c) 2000 Entrust.net Limited,
1294 OU=www.entrust.net/SSL_CPS incorp. by ref. (limits liab.),
1295 O=Entrust.net
1296
1297 * Alias: godaddyclass2ca
1298 Owner DN: OU=Go Daddy Class 2 Certification Authority,
1299 O="The Go Daddy Group, Inc.", C=US
1300
1301 * Alias: starfieldclass2ca
1302 Owner DN: OU=Starfield Class 2 Certification Authority,
1303 O="Starfield Technologies, Inc.", C=US
1304
1305 * Alias: valicertclass2ca
1306 Owner DN: EMAILADDRESS=info@valicert.com,
1307 CN=http://www.valicert.com/,
1308 OU=ValiCert Class 2 Policy Validation Authority,
1309 O="ValiCert, Inc.", L=ValiCert Validation Network
1310
1311 * Alias: geotrustglobalca
1312 Owner DN: CN=GeoTrust Global CA,
1313 O=GeoTrust Inc., C=US
1314
1315 * Alias: equifaxsecureca
1316 Owner DN: OU=Equifax Secure Certificate Authority,
1317 O=Equifax, C=US
1318
1319 * Alias: equifaxsecureebusinessca1
1320 Owner DN: CN=Equifax Secure eBusiness CA-1,
1321 O=Equifax Secure Inc., C=US
1322
1323 * Alias: equifaxsecureebusinessca2
1324 Owner DN: OU=Equifax Secure eBusiness CA-2,
1325 O=Equifax Secure, C=US
1326
1327 * Alias: equifaxsecureglobalebusinessca1
1328 Owner DN: CN=Equifax Secure Global eBusiness CA-1,
1329 O=Equifax Secure Inc., C=US
1330
1331 * Alias: soneraclass1ca
1332 Owner DN: CN=Sonera Class1 CA, O=Sonera, C=FI
1333
1334 * Alias: soneraclass2ca
1335 Owner DN: CN=Sonera Class2 CA, O=Sonera, C=FI
1336
1337 * Alias: comodoaaaca
1338 Owner DN: CN=AAA Certificate Services,
1339 O=Comodo CA Limited, L=Salford, ST=Greater Manchester, C=GB
1340
1341 * Alias: addtrustclass1ca
1342 Owner DN: CN=AddTrust Class 1 CA Root,
1343 OU=AddTrust TTP Network, O=AddTrust AB, C=SE
1344
1345 * Alias: addtrustexternalca
1346 Owner DN: CN=AddTrust External CA Root,
1347 OU=AddTrust External TTP Network, O=AddTrust AB, C=SE
1348
1349 * Alias: addtrustqualifiedca
1350 Owner DN: CN=AddTrust Qualified CA Root,
1351 OU=AddTrust TTP Network, O=AddTrust AB, C=SE
1352
1353 * Alias: utnuserfirsthardwareca
1354 Owner DN: CN=UTN-USERFirst-Hardware,
1355 OU=http://www.usertrust.com, O=The USERTRUST Network,
1356 L=Salt Lake City, ST=UT, C=US
1357
1358 * Alias: utnuserfirstclientauthemailca
1359 Owner DN: CN=UTN-USERFirst-Client Authentication and Email,
1360 OU=http://www.usertrust.com, O=The USERTRUST Network,
1361 L=Salt Lake City, ST=UT, C=US
1362
1363 * Alias: utndatacorpsgcca
1364 Owner DN: CN=UTN - DATACorp SGC,
1365 OU=http://www.usertrust.com, O=The USERTRUST Network,
1366 L=Salt Lake City, ST=UT, C=US
1367
1368 * Alias: utnuserfirstobjectca
1369 Owner DN: CN=UTN-USERFirst-Object,
1370 OU=http://www.usertrust.com, O=The USERTRUST Network,
1371 L=Salt Lake City, ST=UT, C=US
1372
1373
1374 The initial password of the "cacerts" keystore file is
1375 "changeit". System administrators should change that password and
1376 the default access permission of that file upon installing the
1377 SDK.
1378
1379 IMPORTANT: Verify Your cacerts File
1380
1381
1382 Since you trust the CAs in the cacerts file as entities for
1383 signing and issuing certificates to other entities, you must
1384 manage the cacerts file carefully. The cacerts file should
1385 contain only certificates of the CAs you trust. It is your
1386 responsibility to verify the trusted root CA certificates bun‐
1387 dled in the cacerts file and make your own trust decisions. To
1388 remove an untrusted CA certificate from the cacerts file, use
1389 the delete option of the keytool command. You can find the
1390 cacerts file in the JRE installation directory. Contact your
1391 system administrator if you do not have permission to edit
1392 this file.
1393
1394
1395 o The Internet RFC 1421 Certificate Encoding Standard
1396
1397 Certificates are often stored using the printable encoding format
1398 defined by the Internet RFC 1421 standard, instead of their
1399 binary encoding. This certificate format, also known as "Base 64
1400 encoding", facilitates exporting certificates to other applica‐
1401 tions by email or through some other mechanism.
1402
1403 Certificates read by the -importcert and -printcert commands can
1404 be in either this format or binary encoded.
1405
1406 The -exportcert command by default outputs a certificate in
1407 binary encoding, but will instead output a certificate in the
1408 printable encoding format, if the -rfc option is specified.
1409
1410 The -list command by default prints the MD5 fingerprint of a cer‐
1411 tificate. If the -v option is specified, the certificate is
1412 printed in human-readable format, while if the -rfc option is
1413 specified, the certificate is output in the printable encoding
1414 format.
1415
1416 In its printable encoding format, the encoded certificate is
1417 bounded at the beginning by
1418
1419 -----BEGIN CERTIFICATE-----
1420
1421
1422 and at the end by
1423
1424 -----END CERTIFICATE-----
1425
1426
1427 X.500 Distinguished Names
1428 X.500 Distinguished Names are used to identify entities, such as
1429 those which are named by the subject and issuer (signer) fields of
1430 X.509 certificates. keytool supports the following subparts:
1431
1432 o commonName - common name of a person, e.g., "Susan Jones"
1433
1434 o organizationUnit - small organization (e.g, department or divi‐
1435 sion) name, e.g., "Purchasing"
1436
1437 o organizationName - large organization name, e.g., "ABCSystems,
1438 Inc."
1439
1440 o localityName - locality (city) name, e.g., "Palo Alto"
1441
1442 o stateName - state or province name, e.g., "California"
1443
1444 o country - two-letter country code, e.g., "CH"
1445
1446
1447 When supplying a distinguished name string as the value of a -dname
1448 option, as for the -genkeypair command, the string must be in the
1449 following format:
1450
1451 CN=cName, OU=orgUnit, O=org, L=city, S=state, C=countryCode
1452
1453
1454 where all the italicized items represent actual values and the above
1455 keywords are abbreviations for the following:
1456
1457 CN=commonName
1458 OU=organizationUnit
1459 O=organizationName
1460 L=localityName
1461 S=stateName
1462 C=country
1463
1464
1465 A sample distinguished name string is
1466
1467 CN=Mark Smith, OU=JavaSoft, O=Sun, L=Cupertino, S=California, C=US
1468
1469
1470 and a sample command using such a string is
1471 keytool -genkeypair -dname "CN=Mark Smith, OU=JavaSoft, O=Sun, L=Cupertino,
1472 S=California, C=US" -alias mark
1473
1474
1475 Case does not matter for the keyword abbreviations. For example,
1476 "CN", "cn", and "Cn" are all treated the same.
1477
1478 Order matters; each subcomponent must appear in the designated
1479 order. However, it is not necessary to have all the subcomponents.
1480 You may use a subset, for example:
1481
1482 CN=Steve Meier, OU=SunSoft, O=Sun, C=US
1483
1484
1485 If a distinguished name string value contains a comma, the comma
1486 must be escaped by a "\" character when you specify the string on a
1487 command line, as in
1488
1489 cn=peter schuster, o=Sun Microsystems\, Inc., o=sun, c=us
1490
1491
1492 It is never necessary to specify a distinguished name string on a
1493 command line. If it is needed for a command, but not supplied on the
1494 command line, the user is prompted for each of the subcomponents. In
1495 this case, a comma does not need to be escaped by a "\".
1496
1497 WARNING Regarding Importing Trusted Certificates
1498 IMPORTANT: Be sure to check a certificate very carefully before
1499 importing it as a trusted certificate!
1500
1501 View it first (using the -printcert command, or the -importcert com‐
1502 mand without the -noprompt option), and make sure that the displayed
1503 certificate fingerprint(s) match the expected ones. For example,
1504 suppose someone sends or emails you a certificate, and you put it in
1505 a file named /tmp/cert. Before you consider adding the certificate
1506 to your list of trusted certificates, you can execute a -printcert
1507 command to view its fingerprints, as in
1508
1509 keytool -printcert -file /tmp/cert
1510 Owner: CN=ll, OU=ll, O=ll, L=ll, S=ll, C=ll
1511 Issuer: CN=ll, OU=ll, O=ll, L=ll, S=ll, C=ll
1512 Serial Number: 59092b34
1513 Valid from: Thu Sep 25 18:01:13 PDT 1997 until: Wed Dec 24 17:01:13 PST 1997
1514 Certificate Fingerprints:
1515 MD5: 11:81:AD:92:C8:E5:0E:A2:01:2E:D4:7A:D7:5F:07:6F
1516 SHA1: 20:B6:17:FA:EF:E5:55:8A:D0:71:1F:E8:D6:9D:C0:37:13:0E:5E:FE
1517
1518
1519 Then call or otherwise contact the person who sent the certificate,
1520 and compare the fingerprint(s) that you see with the ones that they
1521 show. Only if the fingerprints are equal is it guaranteed that the
1522 certificate has not been replaced in transit with somebody else's
1523 (for example, an attacker's) certificate. If such an attack took
1524 place, and you did not check the certificate before you imported it,
1525 you would end up trusting anything the attacker has signed (for
1526 example, a JAR file with malicious class files inside).
1527
1528 Note: it is not required that you execute a -printcert command prior
1529 to importing a certificate, since before adding a certificate to the
1530 list of trusted certificates in the keystore, the -importcert com‐
1531 mand prints out the certificate information and prompts you to ver‐
1532 ify it. You then have the option of aborting the import operation.
1533 Note, however, this is only the case if you invoke the -importcert
1534 command without the -noprompt option. If the -noprompt option is
1535 given, there is no interaction with the user.
1536
1537 Warning Regarding Passwords
1538 Most commands operating on a keystore require the store password.
1539 Some commands require a private/secret key password.
1540
1541 Passwords can be specified on the command line (in the -storepass
1542 and -keypass options, respectively). However, a password should not
1543 be specified on a command line or in a script unless it is for test‐
1544 ing purposes, or you are on a secure system.
1545
1546 If you don't specify a required password option on a command line,
1547 you will be prompted for it.
1548
1550 o jar @
1551 http://java.sun.com/javase/6/docs/tooldocs/solaris/jar.html tool
1552 documentation
1553
1554 o jarsigner @
1555 http://java.sun.com/javase/6/docs/tooldocs/solaris/jarsigner.html
1556 tool documentation
1557
1558 o the Security @
1559 http://java.sun.com/docs/books/tutorial/security/index.html trail
1560 of the Java Tutorial @
1561 http://java.sun.com/docs/books/tutorial/trailmap.html for examples
1562 of the use of keytool
1563
1564
1566 The command interface for keytool changed in Java SE 6.
1567
1568 keytool no longer displays password input when entered by users. Since
1569 password input can no longer be viewed when entered, users will be
1570 prompted to re-enter passwords any time a password is being set or
1571 changed (for example, when setting the initial keystore password, or
1572 when changing a key password).
1573
1574 Some commands have simply been renamed, and other commands deemed obso‐
1575 lete are no longer listed in this document. All previous commands (both
1576 renamed and obsolete) are still supported in this release and will con‐
1577 tinue to be supported in future releases. The following summarizes all
1578 of the changes made to the keytool command interface:
1579
1580 Renamed commands:
1581
1582 o -export, renamed to -exportcert
1583
1584 o -genkey, renamed to -genkeypair
1585
1586 o -import, renamed to -importcert
1587
1588
1589 Commands deemed obsolete and no longer documented:
1590
1591 o -keyclone @
1592 http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/key‐
1593 tool.html#keycloneCmd
1594
1595 o -identitydb @
1596 http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/key‐
1597 tool.html#identitydbCmd
1598
1599 o -selfcert @
1600 http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/key‐
1601 tool.html#selfcertCmd
1602
1603
1604 07 Aug 2006 keytool(1)