1 1.1 christos =pod 2 1.1 christos {- OpenSSL::safe::output_do_not_edit_headers(); -} 3 1.1 christos 4 1.1 christos =for comment 5 1.1 christos Original text by James Westby. 6 1.1 christos 7 1.1 christos =head1 NAME 8 1.1 christos 9 1.1 christos openssl-rehash, c_rehash - Create symbolic links to files named by the hash 10 1.1 christos values 11 1.1 christos 12 1.1 christos =head1 SYNOPSIS 13 1.1.1.2 christos 14 1.1 christos =for openssl duplicate options 15 1.1 christos 16 1.1 christos B<openssl> 17 1.1 christos B<rehash> 18 1.1 christos [B<-h>] 19 1.1 christos [B<-help>] 20 1.1 christos [B<-old>] 21 1.1 christos [B<-compat>] 22 1.1 christos [B<-n>] 23 1.1 christos [B<-v>] 24 1.1 christos {- $OpenSSL::safe::opt_provider_synopsis -} 25 1.1 christos [I<directory>] ... 26 1.1 christos 27 1.1 christos B<c_rehash> 28 1.1 christos [B<-h>] 29 1.1 christos [B<-help>] 30 1.1 christos [B<-old>] 31 1.1 christos [B<-n>] 32 1.1 christos [B<-v>] 33 1.1 christos {- $OpenSSL::safe::opt_provider_synopsis -} 34 1.1 christos [I<directory>] ... 35 1.1 christos 36 1.1 christos =head1 DESCRIPTION 37 1.1 christos 38 1.1 christos This command is generally equivalent to the external 39 1.1 christos script B<c_rehash>, 40 1.1 christos except for minor differences noted below. 41 1.1 christos 42 1.1 christos B<openssl rehash> scans directories and calculates a hash value of 43 1.1 christos each F<.pem>, F<.crt>, F<.cer>, or F<.crl> 44 1.1 christos file in the specified directory list and creates symbolic links 45 1.1 christos for each file, where the name of the link is the hash value. 46 1.1 christos (If the platform does not support symbolic links, a copy is made.) 47 1.1 christos This command is useful as many programs that use OpenSSL require 48 1.1 christos directories to be set up like this in order to find certificates. 49 1.1 christos 50 1.1 christos If any directories are named on the command line, then those are 51 1.1 christos processed in turn. If not, then the B<SSL_CERT_DIR> environment variable 52 1.1.1.3 christos is consulted; this should be a colon-separated list of directories 53 1.1.1.3 christos (or semicolon-separated on Windows), like the B<PATH> variable. 54 1.1 christos If that is not set then the default directory (installation-specific 55 1.1 christos but often F</usr/local/ssl/certs>) is processed. 56 1.1 christos 57 1.1 christos In order for a directory to be processed, the user must have write 58 1.1 christos permissions on that directory, otherwise an error will be generated. 59 1.1 christos 60 1.1 christos The links created are of the form I<HHHHHHHH.D>, where each I<H> 61 1.1 christos is a hexadecimal character and I<D> is a single decimal digit. 62 1.1 christos When a directory is processed, all links in it that have a name 63 1.1 christos in that syntax are first removed, even if they are being used for 64 1.1 christos some other purpose. 65 1.1 christos To skip the removal step, use the B<-n> flag. 66 1.1 christos Hashes for CRL's look similar except the letter B<r> appears after 67 1.1 christos the period, like this: I<HHHHHHHH.>B<r>I<D>. 68 1.1 christos 69 1.1 christos Multiple objects may have the same hash; they will be indicated by 70 1.1 christos incrementing the I<D> value. Duplicates are found by comparing the 71 1.1 christos full SHA-1 fingerprint. A warning will be displayed if a duplicate 72 1.1 christos is found. 73 1.1 christos 74 1.1 christos A warning will also be displayed if there are files that 75 1.1 christos cannot be parsed as either a certificate or a CRL or if 76 1.1 christos more than one such object appears in the file. 77 1.1 christos 78 1.1 christos =head2 Script Configuration 79 1.1 christos 80 1.1 christos The B<c_rehash> script 81 1.1 christos uses the B<openssl> program to compute the hashes and 82 1.1 christos fingerprints. If not found in the user's B<PATH>, then set the 83 1.1 christos B<OPENSSL> environment variable to the full pathname. 84 1.1 christos Any program can be used, it will be invoked as follows for either 85 1.1 christos a certificate or CRL: 86 1.1 christos 87 1.1 christos $OPENSSL x509 -hash -fingerprint -noout -in FILENAME 88 1.1 christos $OPENSSL crl -hash -fingerprint -noout -in FILENAME 89 1.1 christos 90 1.1 christos where I<FILENAME> is the filename. It must output the hash of the 91 1.1 christos file on the first line, and the fingerprint on the second, 92 1.1 christos optionally prefixed with some text and an equals sign. 93 1.1 christos 94 1.1 christos =head1 OPTIONS 95 1.1 christos 96 1.1 christos =over 4 97 1.1 christos 98 1.1 christos =item B<-help> B<-h> 99 1.1 christos 100 1.1 christos Display a brief usage message. 101 1.1 christos 102 1.1 christos =item B<-old> 103 1.1 christos 104 1.1 christos Use old-style hashing (MD5, as opposed to SHA-1) for generating 105 1.1 christos links to be used for releases before 1.0.0. 106 1.1 christos Note that current versions will not use the old style. 107 1.1 christos 108 1.1 christos =item B<-n> 109 1.1 christos 110 1.1 christos Do not remove existing links. 111 1.1 christos This is needed when keeping new and old-style links in the same directory. 112 1.1 christos 113 1.1 christos =item B<-compat> 114 1.1 christos 115 1.1 christos Generate links for both old-style (MD5) and new-style (SHA1) hashing. 116 1.1 christos This allows releases before 1.0.0 to use these links along-side newer 117 1.1 christos releases. 118 1.1 christos 119 1.1 christos =item B<-v> 120 1.1 christos 121 1.1 christos Print messages about old links removed and new links created. 122 1.1 christos By default, this command only lists each directory as it is processed. 123 1.1 christos 124 1.1 christos {- $OpenSSL::safe::opt_provider_item -} 125 1.1 christos 126 1.1 christos =back 127 1.1 christos 128 1.1 christos =head1 ENVIRONMENT 129 1.1 christos 130 1.1 christos =over 4 131 1.1 christos 132 1.1 christos =item B<OPENSSL> 133 1.1 christos 134 1.1 christos The path to an executable to use to generate hashes and 135 1.1 christos fingerprints (see above). 136 1.1 christos 137 1.1 christos =item B<SSL_CERT_DIR> 138 1.1 christos 139 1.1 christos Colon separated list of directories to operate on. 140 1.1 christos Ignored if directories are listed on the command line. 141 1.1 christos 142 1.1 christos =back 143 1.1 christos 144 1.1 christos =head1 SEE ALSO 145 1.1 christos 146 1.1 christos L<openssl(1)>, 147 1.1 christos L<openssl-crl(1)>, 148 1.1 christos L<openssl-x509(1)> 149 1.1 christos 150 1.1 christos =head1 COPYRIGHT 151 1.1 christos 152 1.1.1.3 christos Copyright 2015-2026 The OpenSSL Project Authors. All Rights Reserved. 153 1.1 christos 154 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 155 1.1 christos this file except in compliance with the License. You can obtain a copy 156 1.1 christos in the file LICENSE in the source distribution or at 157 1.1 christos L<https://www.openssl.org/source/license.html>. 158 1.1 christos 159 1.1 christos =cut 160