Groundwork for a perl based testing framework
[openssl.git] / doc / apps / rehash.pod
1 =pod
2
3 =for comment
4 Original text by James Westby, contributed under the OpenSSL license.
5
6 =head1 NAME
7
8 c_rehash, rehash - Create symbolic links to files named by the hash values
9
10 =head1 SYNOPSIS
11
12 B<openssl>
13 B<rehash>
14 B<[-old]>
15 B<[-h]>
16 B<[-n]>
17 B<[-v]>
18 [ I<directory>...]
19
20 B<c_rehash>
21 I<flags...>
22
23 =head1 DESCRIPTION
24
25 On some platforms, the OpenSSL B<rehash> command is available as
26 an external script called B<c_rehash>.  They are functionally equivalent.
27
28 B<rehash> scans directories and calculates a hash value of each
29 C<.pem>, C<.crt>, C<.cer>, or C<.crl>
30 file in the specified directory list and creates symbolic links
31 for each file, where the name of the link is the hash value.
32 (If the platform does not support symbolic links, a copy is made.)
33 This utility is useful as many programs that use OpenSSL require
34 directories to be set up like this in order to find certificates.
35
36 If any directories are named on the command line, then those are
37 processed in turn. If not, then the B<SSL_CERT_DIR> environment variable
38 is consulted; this should be a colon-separated list of directories,
39 like the Unix B<PATH> variable.
40 If that is not set then the default directory (installation-specific
41 but often B</usr/local/ssl/certs>) is processed.
42
43 In order for a directory to be processed, the user must have write
44 permissions on that directory, otherwise it will be skipped.
45 The links created are of the form C<HHHHHHHH.D>, where each B<H>
46 is a hexadecimal character and B<D> is a single decimal digit.
47 When processing a directory, B<rehash> will first remove all links
48 that have a name in that syntax. If you have links in that format
49 used for other purposes, they will be removed.
50 To skip the removal step, use the B<-n> flag.
51 Hashes for CRL's look similar except the letter B<r> appears after
52 the period, like this: C<HHHHHHHH.rD>.
53
54 Multiple objects may have the same hash; they will be indicated by
55 incrementing the B<D> value. Duplicates are found by comparing the
56 full SHA-1 fingerprint. A warning will be displayed if a duplicate
57 is found.
58
59 A warning will also be displayed if there are files that
60 cannot be parsed as either a certificate or a CRL.
61
62 The program uses the B<openssl> program to compute the hashes and
63 fingerprints. If not found in the user's B<PATH>, then set the
64 B<OPENSSL> environment variable to the full pathname.
65 Any program can be used, it will be invoked as follows for either
66 a certificate or CRL:
67
68   $OPENSSL x509 -hash -fingerprint -noout -in FILENAME
69   $OPENSSL crl -hash -fingerprint -noout -in FILENAME
70
71 where B<FILENAME> is the filename. It must output the hash of the
72 file on the first line, and the fingerprint on the second,
73 optionally prefixed with some text and an equals sign.
74
75 =head1 OPTIONS
76
77 =over 4
78
79 =item B<-old>
80
81 Use old-style hashing (MD5, as opposed to SHA-1) for generating
82 links for releases before 1.0.0.  Note that current versions will
83 not use the old style.
84
85 =item B<-h>
86
87 Display a brief usage message.
88
89 =item B<-n>
90
91 Do not remove existing links.
92 This is needed when keeping new and old-style links in the same directory.
93
94 =item B<-v>
95
96 Print messages about old links removed and new links created.
97 By default, B<rehash> only lists each directory as it is processed.
98
99 =back
100
101 =head1 ENVIRONMENT
102
103 =over
104
105 =item B<OPENSSL>
106
107 The path to an executable to use to generate hashes and
108 fingerprints (see above).
109
110 =item B<SSL_CERT_DIR>
111
112 Colon separated list of directories to operate on.
113 Ignored if directories are listed on the command line.
114
115 =back
116
117 =head1 SEE ALSO
118
119 L<openssl(1)>,
120 L<crl(1)>.
121 L<x509(1)>.