summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libssl/src/doc/HOWTO/certificates.txt105
-rw-r--r--src/lib/libssl/src/doc/HOWTO/keys.txt73
-rw-r--r--src/lib/libssl/src/doc/HOWTO/proxy_certificates.txt322
-rw-r--r--src/lib/libssl/src/doc/README12
-rw-r--r--src/lib/libssl/src/doc/apps/CA.pl.pod179
-rw-r--r--src/lib/libssl/src/doc/apps/tsget.pod194
-rw-r--r--src/lib/libssl/src/doc/apps/verify.pod3
-rw-r--r--src/lib/libssl/src/doc/apps/x509.pod2
-rw-r--r--src/lib/libssl/src/doc/c-indentation.el45
-rw-r--r--src/lib/libssl/src/doc/fingerprints.txt57
-rw-r--r--src/lib/libssl/src/doc/openssl-shared.txt32
-rw-r--r--src/lib/libssl/src/doc/openssl_button.gifbin2063 -> 0 bytes
-rw-r--r--src/lib/libssl/src/doc/openssl_button.html7
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod17
-rw-r--r--src/lib/libssl/src/tools/c89.sh15
-rw-r--r--src/lib/libssl/src/tools/c_hash9
-rw-r--r--src/lib/libssl/src/tools/c_info12
-rw-r--r--src/lib/libssl/src/tools/c_issuer10
-rw-r--r--src/lib/libssl/src/tools/c_name10
-rw-r--r--src/lib/libssl/src/tools/c_rehash.in180
20 files changed, 17 insertions, 1267 deletions
diff --git a/src/lib/libssl/src/doc/HOWTO/certificates.txt b/src/lib/libssl/src/doc/HOWTO/certificates.txt
deleted file mode 100644
index a8a34c7abc..0000000000
--- a/src/lib/libssl/src/doc/HOWTO/certificates.txt
+++ /dev/null
@@ -1,105 +0,0 @@
1<DRAFT!>
2 HOWTO certificates
3
41. Introduction
5
6How you handle certificates depend a great deal on what your role is.
7Your role can be one or several of:
8
9 - User of some client software
10 - User of some server software
11 - Certificate authority
12
13This file is for users who wish to get a certificate of their own.
14Certificate authorities should read ca.txt.
15
16In all the cases shown below, the standard configuration file, as
17compiled into openssl, will be used. You may find it in /etc/,
18/usr/local/ssl/ or somewhere else. The name is openssl.cnf, and
19is better described in another HOWTO <config.txt?>. If you want to
20use a different configuration file, use the argument '-config {file}'
21with the command shown below.
22
23
242. Relationship with keys
25
26Certificates are related to public key cryptography by containing a
27public key. To be useful, there must be a corresponding private key
28somewhere. With OpenSSL, public keys are easily derived from private
29keys, so before you create a certificate or a certificate request, you
30need to create a private key.
31
32Private keys are generated with 'openssl genrsa' if you want a RSA
33private key, or 'openssl gendsa' if you want a DSA private key.
34Further information on how to create private keys can be found in
35another HOWTO <keys.txt?>. The rest of this text assumes you have
36a private key in the file privkey.pem.
37
38
393. Creating a certificate request
40
41To create a certificate, you need to start with a certificate
42request (or, as some certificate authorities like to put
43it, "certificate signing request", since that's exactly what they do,
44they sign it and give you the result back, thus making it authentic
45according to their policies). A certificate request can then be sent
46to a certificate authority to get it signed into a certificate, or if
47you have your own certificate authority, you may sign it yourself, or
48if you need a self-signed certificate (because you just want a test
49certificate or because you are setting up your own CA).
50
51The certificate request is created like this:
52
53 openssl req -new -key privkey.pem -out cert.csr
54
55Now, cert.csr can be sent to the certificate authority, if they can
56handle files in PEM format. If not, use the extra argument '-outform'
57followed by the keyword for the format to use (see another HOWTO
58<formats.txt?>). In some cases, that isn't sufficient and you will
59have to be more creative.
60
61When the certificate authority has then done the checks the need to
62do (and probably gotten payment from you), they will hand over your
63new certificate to you.
64
65Section 5 will tell you more on how to handle the certificate you
66received.
67
68
694. Creating a self-signed test certificate
70
71If you don't want to deal with another certificate authority, or just
72want to create a test certificate for yourself. This is similar to
73creating a certificate request, but creates a certificate instead of
74a certificate request. This is NOT the recommended way to create a
75CA certificate, see ca.txt.
76
77 openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
78
79
805. What to do with the certificate
81
82If you created everything yourself, or if the certificate authority
83was kind enough, your certificate is a raw DER thing in PEM format.
84Your key most definitely is if you have followed the examples above.
85However, some (most?) certificate authorities will encode them with
86things like PKCS7 or PKCS12, or something else. Depending on your
87applications, this may be perfectly OK, it all depends on what they
88know how to decode. If not, There are a number of OpenSSL tools to
89convert between some (most?) formats.
90
91So, depending on your application, you may have to convert your
92certificate and your key to various formats, most often also putting
93them together into one file. The ways to do this is described in
94another HOWTO <formats.txt?>, I will just mention the simplest case.
95In the case of a raw DER thing in PEM format, and assuming that's all
96right for yor applications, simply concatenating the certificate and
97the key into a new file and using that one should be enough. With
98some applications, you don't even have to do that.
99
100
101By now, you have your cetificate and your private key and can start
102using the software that depend on it.
103
104--
105Richard Levitte
diff --git a/src/lib/libssl/src/doc/HOWTO/keys.txt b/src/lib/libssl/src/doc/HOWTO/keys.txt
deleted file mode 100644
index 7ae2a3a118..0000000000
--- a/src/lib/libssl/src/doc/HOWTO/keys.txt
+++ /dev/null
@@ -1,73 +0,0 @@
1<DRAFT!>
2 HOWTO keys
3
41. Introduction
5
6Keys are the basis of public key algorithms and PKI. Keys usually
7come in pairs, with one half being the public key and the other half
8being the private key. With OpenSSL, the private key contains the
9public key information as well, so a public key doesn't need to be
10generated separately.
11
12Public keys come in several flavors, using different cryptographic
13algorithms. The most popular ones associated with certificates are
14RSA and DSA, and this HOWTO will show how to generate each of them.
15
16
172. To generate a RSA key
18
19A RSA key can be used both for encryption and for signing.
20
21Generating a key for the RSA algorithm is quite easy, all you have to
22do is the following:
23
24 openssl genrsa -des3 -out privkey.pem 2048
25
26With this variant, you will be prompted for a protecting password. If
27you don't want your key to be protected by a password, remove the flag
28'-des3' from the command line above.
29
30 NOTE: if you intend to use the key together with a server
31 certificate, it may be a good thing to avoid protecting it
32 with a password, since that would mean someone would have to
33 type in the password every time the server needs to access
34 the key.
35
36The number 2048 is the size of the key, in bits. Today, 2048 or
37higher is recommended for RSA keys, as fewer amount of bits is
38consider insecure or to be insecure pretty soon.
39
40
413. To generate a DSA key
42
43A DSA key can be used for signing only. This is important to keep
44in mind to know what kind of purposes a certificate request with a
45DSA key can really be used for.
46
47Generating a key for the DSA algorithm is a two-step process. First,
48you have to generate parameters from which to generate the key:
49
50 openssl dsaparam -out dsaparam.pem 2048
51
52The number 2048 is the size of the key, in bits. Today, 2048 or
53higher is recommended for DSA keys, as fewer amount of bits is
54consider insecure or to be insecure pretty soon.
55
56When that is done, you can generate a key using the parameters in
57question (actually, several keys can be generated from the same
58parameters):
59
60 openssl gendsa -des3 -out privkey.pem dsaparam.pem
61
62With this variant, you will be prompted for a protecting password. If
63you don't want your key to be protected by a password, remove the flag
64'-des3' from the command line above.
65
66 NOTE: if you intend to use the key together with a server
67 certificate, it may be a good thing to avoid protecting it
68 with a password, since that would mean someone would have to
69 type in the password every time the server needs to access
70 the key.
71
72--
73Richard Levitte
diff --git a/src/lib/libssl/src/doc/HOWTO/proxy_certificates.txt b/src/lib/libssl/src/doc/HOWTO/proxy_certificates.txt
deleted file mode 100644
index f98ec36076..0000000000
--- a/src/lib/libssl/src/doc/HOWTO/proxy_certificates.txt
+++ /dev/null
@@ -1,322 +0,0 @@
1<DRAFT!>
2 HOWTO proxy certificates
3
40. WARNING
5
6NONE OF THE CODE PRESENTED HERE HAVE BEEN CHECKED! They are just an
7example to show you how things can be done. There may be typos or
8type conflicts, and you will have to resolve them.
9
101. Introduction
11
12Proxy certificates are defined in RFC 3820. They are really usual
13certificates with the mandatory extension proxyCertInfo.
14
15Proxy certificates are issued by an End Entity (typically a user),
16either directly with the EE certificate as issuing certificate, or by
17extension through an already issued proxy certificate.. They are used
18to extend rights to some other entity (a computer process, typically,
19or sometimes to the user itself), so it can perform operations in the
20name of the owner of the EE certificate.
21
22See http://www.ietf.org/rfc/rfc3820.txt for more information.
23
24
252. A warning about proxy certificates
26
27Noone seems to have tested proxy certificates with security in mind.
28Basically, to this date, it seems that proxy certificates have only
29been used in a world that's highly aware of them. What would happen
30if an unsuspecting application is to validate a chain of certificates
31that contains proxy certificates? It would usually consider the leaf
32to be the certificate to check for authorisation data, and since proxy
33certificates are controlled by the EE certificate owner alone, it's
34would be normal to consider what the EE certificate owner could do
35with them.
36
37subjectAltName and issuerAltName are forbidden in proxy certificates,
38and this is enforced in OpenSSL. The subject must be the same as the
39issuer, with one commonName added on.
40
41Possible threats are, as far as has been imagined so far:
42
43 - impersonation through commonName (think server certificates).
44 - use of additional extensions, possibly non-standard ones used in
45 certain environments, that would grant extra or different
46 authorisation rights.
47
48For this reason, OpenSSL requires that the use of proxy certificates
49be explicitely allowed. Currently, this can be done using the
50following methods:
51
52 - if the application calls X509_verify_cert() itself, it can do the
53 following prior to that call (ctx is the pointer passed in the call
54 to X509_verify_cert()):
55
56 X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
57
58 - in all other cases, proxy certificate validation can be enabled
59 before starting the application by setting the envirnoment variable
60 OPENSSL_ALLOW_PROXY_CERTS with some non-empty value.
61
62There are thoughts to allow proxy certificates with a line in the
63default openssl.cnf, but that's still in the future.
64
65
663. How to create proxy cerificates
67
68It's quite easy to create proxy certificates, by taking advantage of
69the lack of checks of the 'openssl x509' application (*ahem*). But
70first, you need to create a configuration section that contains a
71definition of the proxyCertInfo extension, a little like this:
72
73 [ v3_proxy ]
74 # A proxy certificate MUST NEVER be a CA certificate.
75 basicConstraints=CA:FALSE
76
77 # Usual authority key ID
78 authorityKeyIdentifier=keyid,issuer:always
79
80 # Now, for the extension that marks this certificate as a proxy one
81 proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:1,policy:text:AB
82
83It's also possible to give the proxy extension in a separate section:
84
85 proxyCertInfo=critical,@proxy_ext
86
87 [ proxy_ext ]
88 language=id-ppl-anyLanguage
89 pathlen=0
90 policy=text:BC
91
92The policy value has a specific syntax, {syntag}:{string}, where the
93syntag determines what will be done with the string. The recognised
94syntags are as follows:
95
96 text indicates that the string is simply the bytes, not
97 encoded in any kind of way:
98
99 policy=text:räksmörgås
100
101 Previous versions of this design had a specific tag
102 for UTF-8 text. However, since the bytes are copied
103 as-is anyway, there's no need for it. Instead, use
104 the text: tag, like this:
105
106 policy=text:räksmörgås
107
108 hex indicates the string is encoded in hex, with colons
109 between each byte (every second hex digit):
110
111 policy=hex:72:E4:6B:73:6D:F6:72:67:E5:73
112
113 Previous versions of this design had a tag to insert a
114 complete DER blob. However, the only legal use for
115 this would be to surround the bytes that would go with
116 the hex: tag with what's needed to construct a correct
117 OCTET STRING. Since hex: does that, the DER tag felt
118 superfluous, and was therefore removed.
119
120 file indicates that the text of the policy should really be
121 taken from a file. The string is then really a file
122 name. This is useful for policies that are large
123 (more than a few of lines) XML documents, for example.
124
125The 'policy' setting can be split up in multiple lines like this:
126
127 0.policy=This is
128 1.polisy= a multi-
129 2.policy=line policy.
130
131NOTE: the proxy policy value is the part that determines the rights
132granted to the process using the proxy certificate. The value is
133completely dependent on the application reading and interpretting it!
134
135Now that you have created an extension section for your proxy
136certificate, you can now easily create a proxy certificate like this:
137
138 openssl req -new -config openssl.cnf \
139 -out proxy.req -keyout proxy.key
140 openssl x509 -req -CAcreateserial -in proxy.req -days 7 \
141 -out proxy.crt -CA user.crt -CAkey user.key \
142 -extfile openssl.cnf -extensions v3_proxy
143
144It's just as easy to create a proxy certificate using another proxy
145certificate as issuer (note that I'm using a different configuration
146section for it):
147
148 openssl req -new -config openssl.cnf \
149 -out proxy2.req -keyout proxy2.key
150 openssl x509 -req -CAcreateserial -in proxy2.req -days 7 \
151 -out proxy2.crt -CA proxy.crt -CAkey proxy.key \
152 -extfile openssl.cnf -extensions v3_proxy2
153
154
1554. How to have your application interpret the policy?
156
157The basic way to interpret proxy policies is to prepare some default
158rights, then do a check of the proxy certificate against the a chain
159of proxy certificates, user certificate and CA certificates, and see
160what rights came out by the end. Sounds easy, huh? It almost is.
161
162The slightly complicated part is how to pass data between your
163application and the certificate validation procedure.
164
165You need the following ingredients:
166
167 - a callback routing that will be called for every certificate that's
168 validated. It will be called several times for each certificates,
169 so you must be attentive to when it's a good time to do the proxy
170 policy interpretation and check, as well as to fill in the defaults
171 when the EE certificate is checked.
172
173 - a structure of data that's shared between your application code and
174 the callback.
175
176 - a wrapper function that sets it all up.
177
178 - an ex_data index function that creates an index into the generic
179 ex_data store that's attached to an X509 validation context.
180
181This is some cookbook code for you to fill in:
182
183 /* In this example, I will use a view of granted rights as a bit
184 array, one bit for each possible right. */
185 typedef struct your_rights {
186 unsigned char rights[total_rights / 8];
187 } YOUR_RIGHTS;
188
189 /* The following procedure will create an index for the ex_data
190 store in the X509 validation context the first time it's called.
191 Subsequent calls will return the same index. */
192 static int get_proxy_auth_ex_data_idx(void)
193 {
194 static volatile int idx = -1;
195 if (idx < 0)
196 {
197 CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
198 if (idx < 0)
199 {
200 idx = X509_STORE_CTX_get_ex_new_index(0,
201 "for verify callback",
202 NULL,NULL,NULL);
203 }
204 CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
205 }
206 return idx;
207 }
208
209 /* Callback to be given to the X509 validation procedure. */
210 static int verify_callback(int ok, X509_STORE_CTX *ctx)
211 {
212 if (ok == 1) /* It's REALLY important you keep the proxy policy
213 check within this secion. It's important to know
214 that when ok is 1, the certificates are checked
215 from top to bottom. You get the CA root first,
216 followed by the possible chain of intermediate
217 CAs, followed by the EE certificate, followed by
218 the possible proxy certificates. */
219 {
220 X509 *xs = ctx->current_cert;
221
222 if (xs->ex_flags & EXFLAG_PROXY)
223 {
224 YOUR_RIGHTS *rights =
225 (YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
226 get_proxy_auth_ex_data_idx());
227 PROXY_CERT_INFO_EXTENSION *pci =
228 X509_get_ext_d2i(xs, NID_proxyCertInfo, NULL, NULL);
229
230 switch (OBJ_obj2nid(pci->proxyPolicy->policyLanguage))
231 {
232 case NID_Independent:
233 /* Do whatever you need to grant explicit rights to
234 this particular proxy certificate, usually by
235 pulling them from some database. If there are none
236 to be found, clear all rights (making this and any
237 subsequent proxy certificate void of any rights).
238 */
239 memset(rights->rights, 0, sizeof(rights->rights));
240 break;
241 case NID_id_ppl_inheritAll:
242 /* This is basically a NOP, we simply let the current
243 rights stand as they are. */
244 break;
245 default:
246 /* This is usually the most complex section of code.
247 You really do whatever you want as long as you
248 follow RFC 3820. In the example we use here, the
249 simplest thing to do is to build another, temporary
250 bit array and fill it with the rights granted by
251 the current proxy certificate, then use it as a
252 mask on the accumulated rights bit array, and
253 voilà, you now have a new accumulated rights bit
254 array. */
255 {
256 int i;
257 YOUR_RIGHTS tmp_rights;
258 memset(tmp_rights.rights, 0, sizeof(tmp_rights.rights));
259
260 /* process_rights() is supposed to be a procedure
261 that takes a string and it's length, interprets
262 it and sets the bits in the YOUR_RIGHTS pointed
263 at by the third argument. */
264 process_rights((char *) pci->proxyPolicy->policy->data,
265 pci->proxyPolicy->policy->length,
266 &tmp_rights);
267
268 for(i = 0; i < total_rights / 8; i++)
269 rights->rights[i] &= tmp_rights.rights[i];
270 }
271 break;
272 }
273 PROXY_CERT_INFO_EXTENSION_free(pci);
274 }
275 else if (!(xs->ex_flags & EXFLAG_CA))
276 {
277 /* We have a EE certificate, let's use it to set default!
278 */
279 YOUR_RIGHTS *rights =
280 (YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
281 get_proxy_auth_ex_data_idx());
282
283 /* The following procedure finds out what rights the owner
284 of the current certificate has, and sets them in the
285 YOUR_RIGHTS structure pointed at by the second
286 argument. */
287 set_default_rights(xs, rights);
288 }
289 }
290 return ok;
291 }
292
293 static int my_X509_verify_cert(X509_STORE_CTX *ctx,
294 YOUR_RIGHTS *needed_rights)
295 {
296 int i;
297 int (*save_verify_cb)(int ok,X509_STORE_CTX *ctx) = ctx->verify_cb;
298 YOUR_RIGHTS rights;
299
300 X509_STORE_CTX_set_verify_cb(ctx, verify_callback);
301 X509_STORE_CTX_set_ex_data(ctx, get_proxy_auth_ex_data_idx(), &rights);
302 X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
303 ok = X509_verify_cert(ctx);
304
305 if (ok == 1)
306 {
307 ok = check_needed_rights(rights, needed_rights);
308 }
309
310 X509_STORE_CTX_set_verify_cb(ctx, save_verify_cb);
311
312 return ok;
313 }
314
315If you use SSL or TLS, you can easily set up a callback to have the
316certificates checked properly, using the code above:
317
318 SSL_CTX_set_cert_verify_callback(s_ctx, my_X509_verify_cert, &needed_rights);
319
320
321--
322Richard Levitte
diff --git a/src/lib/libssl/src/doc/README b/src/lib/libssl/src/doc/README
deleted file mode 100644
index 6ecc14d994..0000000000
--- a/src/lib/libssl/src/doc/README
+++ /dev/null
@@ -1,12 +0,0 @@
1
2 apps/openssl.pod .... Documentation of OpenSSL `openssl' command
3 crypto/crypto.pod ... Documentation of OpenSSL crypto.h+libcrypto.a
4 ssl/ssl.pod ......... Documentation of OpenSSL ssl.h+libssl.a
5 openssl.txt ......... Assembled documentation files for OpenSSL [not final]
6 ssleay.txt .......... Assembled documentation of ancestor SSLeay [obsolete]
7 standards.txt ....... Assembled pointers to standards, RFCs or internet drafts
8 that are related to OpenSSL.
9
10 An archive of HTML documents for the SSLeay library is available from
11 http://www.columbia.edu/~ariel/ssleay/
12
diff --git a/src/lib/libssl/src/doc/apps/CA.pl.pod b/src/lib/libssl/src/doc/apps/CA.pl.pod
deleted file mode 100644
index d326101cde..0000000000
--- a/src/lib/libssl/src/doc/apps/CA.pl.pod
+++ /dev/null
@@ -1,179 +0,0 @@
1
2=pod
3
4=head1 NAME
5
6CA.pl - friendlier interface for OpenSSL certificate programs
7
8=head1 SYNOPSIS
9
10B<CA.pl>
11[B<-?>]
12[B<-h>]
13[B<-help>]
14[B<-newcert>]
15[B<-newreq>]
16[B<-newreq-nodes>]
17[B<-newca>]
18[B<-xsign>]
19[B<-sign>]
20[B<-signreq>]
21[B<-signcert>]
22[B<-verify>]
23[B<files>]
24
25=head1 DESCRIPTION
26
27The B<CA.pl> script is a perl script that supplies the relevant command line
28arguments to the B<openssl> command for some common certificate operations.
29It is intended to simplify the process of certificate creation and management
30by the use of some simple options.
31
32=head1 COMMAND OPTIONS
33
34=over 4
35
36=item B<?>, B<-h>, B<-help>
37
38prints a usage message.
39
40=item B<-newcert>
41
42creates a new self signed certificate. The private key is written to the file
43"newkey.pem" and the request written to the file "newreq.pem".
44
45=item B<-newreq>
46
47creates a new certificate request. The private key is written to the file
48"newkey.pem" and the request written to the file "newreq.pem".
49
50=item B<-newreq-nodes>
51
52is like B<-newreq> except that the private key will not be encrypted.
53
54=item B<-newca>
55
56creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert>
57and B<-xsign> options). The user is prompted to enter the filename of the CA
58certificates (which should also contain the private key) or by hitting ENTER
59details of the CA will be prompted for. The relevant files and directories
60are created in a directory called "demoCA" in the current directory.
61
62=item B<-pkcs12>
63
64create a PKCS#12 file containing the user certificate, private key and CA
65certificate. It expects the user certificate and private key to be in the
66file "newcert.pem" and the CA certificate to be in the file demoCA/cacert.pem,
67it creates a file "newcert.p12". This command can thus be called after the
68B<-sign> option. The PKCS#12 file can be imported directly into a browser.
69If there is an additional argument on the command line it will be used as the
70"friendly name" for the certificate (which is typically displayed in the browser
71list box), otherwise the name "My Certificate" is used.
72
73=item B<-sign>, B<-signreq>, B<-xsign>
74
75calls the B<ca> program to sign a certificate request. It expects the request
76to be in the file "newreq.pem". The new certificate is written to the file
77"newcert.pem" except in the case of the B<-xsign> option when it is written
78to standard output.
79
80
81=item B<-signCA>
82
83this option is the same as the B<-signreq> option except it uses the configuration
84file section B<v3_ca> and so makes the signed request a valid CA certificate. This
85is useful when creating intermediate CA from a root CA.
86
87=item B<-signcert>
88
89this option is the same as B<-sign> except it expects a self signed certificate
90to be present in the file "newreq.pem".
91
92=item B<-verify>
93
94verifies certificates against the CA certificate for "demoCA". If no certificates
95are specified on the command line it tries to verify the file "newcert.pem".
96
97=item B<files>
98
99one or more optional certificate file names for use with the B<-verify> command.
100
101=back
102
103=head1 EXAMPLES
104
105Create a CA hierarchy:
106
107 CA.pl -newca
108
109Complete certificate creation example: create a CA, create a request, sign
110the request and finally create a PKCS#12 file containing it.
111
112 CA.pl -newca
113 CA.pl -newreq
114 CA.pl -signreq
115 CA.pl -pkcs12 "My Test Certificate"
116
117=head1 DSA CERTIFICATES
118
119Although the B<CA.pl> creates RSA CAs and requests it is still possible to
120use it with DSA certificates and requests using the L<req(1)|req(1)> command
121directly. The following example shows the steps that would typically be taken.
122
123Create some DSA parameters:
124
125 openssl dsaparam -out dsap.pem 1024
126
127Create a DSA CA certificate and private key:
128
129 openssl req -x509 -newkey dsa:dsap.pem -keyout cacert.pem -out cacert.pem
130
131Create the CA directories and files:
132
133 CA.pl -newca
134
135enter cacert.pem when prompted for the CA file name.
136
137Create a DSA certificate request and private key (a different set of parameters
138can optionally be created first):
139
140 openssl req -out newreq.pem -newkey dsa:dsap.pem
141
142Sign the request:
143
144 CA.pl -signreq
145
146=head1 NOTES
147
148Most of the filenames mentioned can be modified by editing the B<CA.pl> script.
149
150If the demoCA directory already exists then the B<-newca> command will not
151overwrite it and will do nothing. This can happen if a previous call using
152the B<-newca> option terminated abnormally. To get the correct behaviour
153delete the demoCA directory if it already exists.
154
155Under some environments it may not be possible to run the B<CA.pl> script
156directly (for example Win32) and the default configuration file location may
157be wrong. In this case the command:
158
159 perl -S CA.pl
160
161can be used and the B<OPENSSL_CONF> environment variable changed to point to
162the correct path of the configuration file "openssl.cnf".
163
164The script is intended as a simple front end for the B<openssl> program for use
165by a beginner. Its behaviour isn't always what is wanted. For more control over the
166behaviour of the certificate commands call the B<openssl> command directly.
167
168=head1 ENVIRONMENT VARIABLES
169
170The variable B<OPENSSL_CONF> if defined allows an alternative configuration
171file location to be specified, it should contain the full path to the
172configuration file, not just its directory.
173
174=head1 SEE ALSO
175
176L<x509(1)|x509(1)>, L<ca(1)|ca(1)>, L<req(1)|req(1)>, L<pkcs12(1)|pkcs12(1)>,
177L<config(5)|config(5)>
178
179=cut
diff --git a/src/lib/libssl/src/doc/apps/tsget.pod b/src/lib/libssl/src/doc/apps/tsget.pod
deleted file mode 100644
index 56db985c4b..0000000000
--- a/src/lib/libssl/src/doc/apps/tsget.pod
+++ /dev/null
@@ -1,194 +0,0 @@
1=pod
2
3=head1 NAME
4
5tsget - Time Stamping HTTP/HTTPS client
6
7=head1 SYNOPSIS
8
9B<tsget>
10B<-h> server_url
11[B<-e> extension]
12[B<-o> output]
13[B<-v>]
14[B<-d>]
15[B<-k> private_key.pem]
16[B<-p> key_password]
17[B<-c> client_cert.pem]
18[B<-C> CA_certs.pem]
19[B<-P> CA_path]
20[B<-r> file:file...]
21[B<-g> EGD_socket]
22[request]...
23
24=head1 DESCRIPTION
25
26The B<tsget> command can be used for sending a time stamp request, as
27specified in B<RFC 3161>, to a time stamp server over HTTP or HTTPS and storing
28the time stamp response in a file. This tool cannot be used for creating the
29requests and verifying responses, you can use the OpenSSL B<ts(1)> command to
30do that. B<tsget> can send several requests to the server without closing
31the TCP connection if more than one requests are specified on the command
32line.
33
34The tool sends the following HTTP request for each time stamp request:
35
36 POST url HTTP/1.1
37 User-Agent: OpenTSA tsget.pl/<version>
38 Host: <host>:<port>
39 Pragma: no-cache
40 Content-Type: application/timestamp-query
41 Accept: application/timestamp-reply
42 Content-Length: length of body
43
44 ...binary request specified by the user...
45
46B<tsget> expects a response of type application/timestamp-reply, which is
47written to a file without any interpretation.
48
49=head1 OPTIONS
50
51=over 4
52
53=item B<-h> server_url
54
55The URL of the HTTP/HTTPS server listening for time stamp requests.
56
57=item B<-e> extension
58
59If the B<-o> option is not given this argument specifies the extension of the
60output files. The base name of the output file will be the same as those of
61the input files. Default extension is '.tsr'. (Optional)
62
63=item B<-o> output
64
65This option can be specified only when just one request is sent to the
66server. The time stamp response will be written to the given output file. '-'
67means standard output. In case of multiple time stamp requests or the absence
68of this argument the names of the output files will be derived from the names
69of the input files and the default or specified extension argument. (Optional)
70
71=item B<-v>
72
73The name of the currently processed request is printed on standard
74error. (Optional)
75
76=item B<-d>
77
78Switches on verbose mode for the underlying B<curl> library. You can see
79detailed debug messages for the connection. (Optional)
80
81=item B<-k> private_key.pem
82
83(HTTPS) In case of certificate-based client authentication over HTTPS
84<private_key.pem> must contain the private key of the user. The private key
85file can optionally be protected by a passphrase. The B<-c> option must also
86be specified. (Optional)
87
88=item B<-p> key_password
89
90(HTTPS) Specifies the passphrase for the private key specified by the B<-k>
91argument. If this option is omitted and the key is passphrase protected B<tsget>
92will ask for it. (Optional)
93
94=item B<-c> client_cert.pem
95
96(HTTPS) In case of certificate-based client authentication over HTTPS
97<client_cert.pem> must contain the X.509 certificate of the user. The B<-k>
98option must also be specified. If this option is not specified no
99certificate-based client authentication will take place. (Optional)
100
101=item B<-C> CA_certs.pem
102
103(HTTPS) The trusted CA certificate store. The certificate chain of the peer's
104certificate must include one of the CA certificates specified in this file.
105Either option B<-C> or option B<-P> must be given in case of HTTPS. (Optional)
106
107=item B<-P> CA_path
108
109(HTTPS) The path containing the trusted CA certificates to verify the peer's
110certificate. The directory must be prepared with the B<c_rehash>
111OpenSSL utility. Either option B<-C> or option B<-P> must be given in case of
112HTTPS. (Optional)
113
114=item B<-rand> file:file...
115
116The files containing random data for seeding the random number
117generator. Multiple files can be specified, the separator is B<;> for
118MS-Windows, B<,> for VMS and B<:> for all other platforms. (Optional)
119
120=item B<-g> EGD_socket
121
122The name of an EGD socket to get random data from. (Optional)
123
124=item [request]...
125
126List of files containing B<RFC 3161> DER-encoded time stamp requests. If no
127requests are specified only one request will be sent to the server and it will be
128read from the standard input. (Optional)
129
130=back
131
132=head1 ENVIRONMENT VARIABLES
133
134The B<TSGET> environment variable can optionally contain default
135arguments. The content of this variable is added to the list of command line
136arguments.
137
138=head1 EXAMPLES
139
140The examples below presume that B<file1.tsq> and B<file2.tsq> contain valid
141time stamp requests, tsa.opentsa.org listens at port 8080 for HTTP requests
142and at port 8443 for HTTPS requests, the TSA service is available at the /tsa
143absolute path.
144
145Get a time stamp response for file1.tsq over HTTP, output is written to
146file1.tsr:
147
148 tsget -h http://tsa.opentsa.org:8080/tsa file1.tsq
149
150Get a time stamp response for file1.tsq and file2.tsq over HTTP showing
151progress, output is written to file1.reply and file2.reply respectively:
152
153 tsget -h http://tsa.opentsa.org:8080/tsa -v -e .reply \
154 file1.tsq file2.tsq
155
156Create a time stamp request, write it to file3.tsq, send it to the server and
157write the response to file3.tsr:
158
159 openssl ts -query -data file3.txt -cert | tee file3.tsq \
160 | tsget -h http://tsa.opentsa.org:8080/tsa \
161 -o file3.tsr
162
163Get a time stamp response for file1.tsq over HTTPS without client
164authentication:
165
166 tsget -h https://tsa.opentsa.org:8443/tsa \
167 -C cacerts.pem file1.tsq
168
169Get a time stamp response for file1.tsq over HTTPS with certificate-based
170client authentication (it will ask for the passphrase if client_key.pem is
171protected):
172
173 tsget -h https://tsa.opentsa.org:8443/tsa -C cacerts.pem \
174 -k client_key.pem -c client_cert.pem file1.tsq
175
176You can shorten the previous command line if you make use of the B<TSGET>
177environment variable. The following commands do the same as the previous
178example:
179
180 TSGET='-h https://tsa.opentsa.org:8443/tsa -C cacerts.pem \
181 -k client_key.pem -c client_cert.pem'
182 export TSGET
183 tsget file1.tsq
184
185=head1 AUTHOR
186
187Zoltan Glozik <zglozik@opentsa.org>, OpenTSA project (http://www.opentsa.org)
188
189=head1 SEE ALSO
190
191L<openssl(1)|openssl(1)>, L<ts(1)|ts(1)>, L<curl(1)|curl(1)>,
192B<RFC 3161>
193
194=cut
diff --git a/src/lib/libssl/src/doc/apps/verify.pod b/src/lib/libssl/src/doc/apps/verify.pod
index da683004bd..f1d5384b9a 100644
--- a/src/lib/libssl/src/doc/apps/verify.pod
+++ b/src/lib/libssl/src/doc/apps/verify.pod
@@ -43,8 +43,7 @@ The B<verify> command verifies certificate chains.
43A directory of trusted certificates. The certificates should have names 43A directory of trusted certificates. The certificates should have names
44of the form: hash.0 or have symbolic links to them of this 44of the form: hash.0 or have symbolic links to them of this
45form ("hash" is the hashed certificate subject name: see the B<-hash> option 45form ("hash" is the hashed certificate subject name: see the B<-hash> option
46of the B<x509> utility). Under Unix the B<c_rehash> script will automatically 46of the B<x509> utility).
47create symbolic links to a directory of certificates.
48 47
49=item B<-CAfile file> 48=item B<-CAfile file>
50 49
diff --git a/src/lib/libssl/src/doc/apps/x509.pod b/src/lib/libssl/src/doc/apps/x509.pod
index d2d9eb812a..314018f086 100644
--- a/src/lib/libssl/src/doc/apps/x509.pod
+++ b/src/lib/libssl/src/doc/apps/x509.pod
@@ -856,6 +856,6 @@ The hash algorithm used in the B<-subject_hash> and B<-issuer_hash> options
856before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding 856before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding
857of the distinguished name. In OpenSSL 1.0.0 and later it is based on a 857of the distinguished name. In OpenSSL 1.0.0 and later it is based on a
858canonical version of the DN using SHA1. This means that any directories using 858canonical version of the DN using SHA1. This means that any directories using
859the old form must have their links rebuilt using B<c_rehash> or similar. 859the old form must have their links rebuilt.
860 860
861=cut 861=cut
diff --git a/src/lib/libssl/src/doc/c-indentation.el b/src/lib/libssl/src/doc/c-indentation.el
deleted file mode 100644
index 90861d3979..0000000000
--- a/src/lib/libssl/src/doc/c-indentation.el
+++ /dev/null
@@ -1,45 +0,0 @@
1; This Emacs Lisp file defines a C indentation style that closely
2; follows most aspects of the one that is used throughout SSLeay,
3; and hence in OpenSSL.
4;
5; This definition is for the "CC mode" package, which is the default
6; mode for editing C source files in Emacs 20, not for the older
7; c-mode.el (which was the default in less recent releaes of Emacs 19).
8;
9; Copy the definition in your .emacs file or use M-x eval-buffer.
10; To activate this indentation style, visit a C file, type
11; M-x c-set-style <RET> (or C-c . for short), and enter "eay".
12; To toggle the auto-newline feature of CC mode, type C-c C-a.
13;
14; Apparently statement blocks that are not introduced by a statement
15; such as "if" and that are not the body of a function cannot
16; be handled too well by CC mode with this indentation style,
17; so you have to indent them manually (you can use C-q tab).
18;
19; For suggesting improvements, please send e-mail to bodo@openssl.org.
20
21(c-add-style "eay"
22 '((c-basic-offset . 8)
23 (indent-tabs-mode . t)
24 (c-comment-only-line-offset . 0)
25 (c-hanging-braces-alist)
26 (c-offsets-alist . ((defun-open . +)
27 (defun-block-intro . 0)
28 (class-open . +)
29 (class-close . +)
30 (block-open . 0)
31 (block-close . 0)
32 (substatement-open . +)
33 (statement . 0)
34 (statement-block-intro . 0)
35 (statement-case-open . +)
36 (statement-case-intro . +)
37 (case-label . -)
38 (label . -)
39 (arglist-cont-nonempty . +)
40 (topmost-intro . -)
41 (brace-list-close . 0)
42 (brace-list-intro . 0)
43 (brace-list-open . +)
44 ))))
45
diff --git a/src/lib/libssl/src/doc/fingerprints.txt b/src/lib/libssl/src/doc/fingerprints.txt
deleted file mode 100644
index 7d05a85594..0000000000
--- a/src/lib/libssl/src/doc/fingerprints.txt
+++ /dev/null
@@ -1,57 +0,0 @@
1 Fingerprints
2
3OpenSSL releases are signed with PGP/GnuPG keys. You can find the
4signatures in separate files in the same location you find the
5distributions themselves. The normal file name is the same as the
6distribution file, with '.asc' added. For example, the signature for
7the distribution of OpenSSL 0.9.7f, openssl-0.9.7f.tar.gz, is found in
8the file openssl-0.9.7f.tar.gz.asc.
9
10The following is the list of fingerprints for the keys that are
11currently in use (have been used since summer 2004) to sign OpenSSL
12distributions:
13
14pub 1024D/F709453B 2003-10-20
15 Key fingerprint = C4CA B749 C34F 7F4C C04F DAC9 A7AF 9E78 F709 453B
16uid Richard Levitte <richard@levitte.org>
17uid Richard Levitte <levitte@openssl.org>
18uid Richard Levitte <levitte@lp.se>
19
20pub 2048R/F295C759 1998-12-13
21 Key fingerprint = D0 5D 8C 61 6E 27 E6 60 41 EC B1 B8 D5 7E E5 97
22uid Dr S N Henson <shenson@drh-consultancy.demon.co.uk>
23
24pub 1024R/49A563D9 1997-02-24
25 Key fingerprint = 7B 79 19 FA 71 6B 87 25 0E 77 21 E5 52 D9 83 BF
26uid Mark Cox <mjc@redhat.com>
27uid Mark Cox <mark@awe.com>
28uid Mark Cox <mjc@apache.org>
29
30pub 1024R/26BB437D 1997-04-28
31 Key fingerprint = 00 C9 21 8E D1 AB 70 37 DD 67 A2 3A 0A 6F 8D A5
32uid Ralf S. Engelschall <rse@engelschall.com>
33
34pub 1024R/9C58A66D 1997-04-03
35 Key fingerprint = 13 D0 B8 9D 37 30 C3 ED AC 9C 24 7D 45 8C 17 67
36uid jaenicke@openssl.org
37uid Lutz Jaenicke <Lutz.Jaenicke@aet.TU-Cottbus.DE>
38
39pub 1024D/2118CF83 1998-07-13
40 Key fingerprint = 7656 55DE 62E3 96FF 2587 EB6C 4F6D E156 2118 CF83
41uid Ben Laurie <ben@thebunker.net>
42uid Ben Laurie <ben@cryptix.org>
43uid Ben Laurie <ben@algroup.co.uk>
44sub 4096g/1F5143E7 1998-07-13
45
46pub 1024R/5A6A9B85 1994-03-22
47 Key fingerprint = C7 AC 7E AD 56 6A 65 EC F6 16 66 83 7E 86 68 28
48uid Bodo Moeller <2005@bmoeller.de>
49uid Bodo Moeller <2003@bmoeller.de>
50uid Bodo Moeller <2004@bmoeller.de>
51uid Bodo Moeller <bmoeller@acm.org>
52uid Bodo Moeller <bodo@openssl.org>
53uid Bodo Moeller <bm@ulf.mali.sub.org>
54uid Bodo Moeller <3moeller@informatik.uni-hamburg.de>
55uid Bodo Moeller <Bodo_Moeller@public.uni-hamburg.de>
56uid Bodo Moeller <3moeller@rzdspc5.informatik.uni-hamburg.de>
57
diff --git a/src/lib/libssl/src/doc/openssl-shared.txt b/src/lib/libssl/src/doc/openssl-shared.txt
deleted file mode 100644
index 5cf84a054f..0000000000
--- a/src/lib/libssl/src/doc/openssl-shared.txt
+++ /dev/null
@@ -1,32 +0,0 @@
1The OpenSSL shared libraries are often installed in a directory like
2/usr/local/ssl/lib.
3
4If this directory is not in a standard system path for dynamic/shared
5libraries, then you will have problems linking and executing
6applications that use OpenSSL libraries UNLESS:
7
8* you link with static (archive) libraries. If you are truly
9 paranoid about security, you should use static libraries.
10* you use the GNU libtool code during linking
11 (http://www.gnu.org/software/libtool/libtool.html)
12* you use pkg-config during linking (this requires that
13 PKG_CONFIG_PATH includes the path to the OpenSSL shared
14 library directory), and make use of -R or -rpath.
15 (http://www.freedesktop.org/software/pkgconfig/)
16* you specify the system-wide link path via a command such
17 as crle(1) on Solaris systems.
18* you add the OpenSSL shared library directory to /etc/ld.so.conf
19 and run ldconfig(8) on Linux systems.
20* you define the LD_LIBRARY_PATH, LIBPATH, SHLIB_PATH (HP),
21 DYLD_LIBRARY_PATH (MacOS X) or PATH (Cygwin and DJGPP)
22 environment variable and add the OpenSSL shared library
23 directory to it.
24
25One common tool to check the dynamic dependencies of an executable
26or dynamic library is ldd(1) on most UNIX systems.
27
28See any operating system documentation and manpages about shared
29libraries for your version of UNIX. The following manpages may be
30helpful: ld(1), ld.so(1), ld.so.1(1) [Solaris], dld.sl(1) [HP],
31ldd(1), crle(1) [Solaris], pldd(1) [Solaris], ldconfig(8) [Linux],
32chatr(1) [HP].
diff --git a/src/lib/libssl/src/doc/openssl_button.gif b/src/lib/libssl/src/doc/openssl_button.gif
deleted file mode 100644
index 3d3c90c9f8..0000000000
--- a/src/lib/libssl/src/doc/openssl_button.gif
+++ /dev/null
Binary files differ
diff --git a/src/lib/libssl/src/doc/openssl_button.html b/src/lib/libssl/src/doc/openssl_button.html
deleted file mode 100644
index 44c91bd3d0..0000000000
--- a/src/lib/libssl/src/doc/openssl_button.html
+++ /dev/null
@@ -1,7 +0,0 @@
1
2<!-- the `Includes OpenSSL Cryptogaphy Software' button -->
3<!-- freely usable by any application linked against OpenSSL -->
4<a href="http://www.openssl.org/">
5<img src="openssl_button.gif"
6 width=102 height=47 border=0></a>
7
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
index de01065285..cd78dd285f 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
@@ -40,7 +40,6 @@ If more than one CA certificate with the same name hash value exist, the
40extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search 40extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search
41is performed in the ordering of the extension number, regardless of other 41is performed in the ordering of the extension number, regardless of other
42properties of the certificates. 42properties of the certificates.
43Use the B<c_rehash> utility to create the necessary links.
44 43
45The certificates in B<CApath> are only looked up when required, e.g. when 44The certificates in B<CApath> are only looked up when required, e.g. when
46building the certificate chain or when actually performing the verification 45building the certificate chain or when actually performing the verification
@@ -92,7 +91,21 @@ Prepare the directory /some/where/certs containing several CA certificates
92for use as B<CApath>: 91for use as B<CApath>:
93 92
94 cd /some/where/certs 93 cd /some/where/certs
95 c_rehash . 94 rm -f *.[0-9]* *.r[0-9]*
95 for c in *.pem; do
96 [ "$c" = "*.pem" ] && continue
97 hash=$(openssl x509 -noout -hash -in "$c")
98 if egrep -q -- '-BEGIN( X509 | TRUSTED | )CERTIFICATE-' "$c"; then
99 suf=0
100 while [ -e $hash.$suf ]; do suf=$(( $suf + 1 )); done
101 ln -s "$c" $hash.$suf
102 fi
103 if egrep -q -- '-BEGIN X509 CRL-' "$c"; then
104 suf=0
105 while [ -e $hash.r$suf ]; do suf=$(( $suf + 1 )); done
106 ln -s "$c" $hash.r$suf
107 fi
108 done
96 109
97=head1 RETURN VALUES 110=head1 RETURN VALUES
98 111
diff --git a/src/lib/libssl/src/tools/c89.sh b/src/lib/libssl/src/tools/c89.sh
deleted file mode 100644
index b25c9fda2d..0000000000
--- a/src/lib/libssl/src/tools/c89.sh
+++ /dev/null
@@ -1,15 +0,0 @@
1#!/bin/sh -k
2#
3# Re-order arguments so that -L comes first
4#
5opts=""
6lopts=""
7
8for arg in $* ; do
9 case $arg in
10 -L*) lopts="$lopts $arg" ;;
11 *) opts="$opts $arg" ;;
12 esac
13done
14
15c89 $lopts $opts
diff --git a/src/lib/libssl/src/tools/c_hash b/src/lib/libssl/src/tools/c_hash
deleted file mode 100644
index 5e0a908175..0000000000
--- a/src/lib/libssl/src/tools/c_hash
+++ /dev/null
@@ -1,9 +0,0 @@
1#!/bin/sh
2# print out the hash values
3#
4
5for i in $*
6do
7 h=`openssl x509 -hash -noout -in $i`
8 echo "$h.0 => $i"
9done
diff --git a/src/lib/libssl/src/tools/c_info b/src/lib/libssl/src/tools/c_info
deleted file mode 100644
index 0e1e633b6f..0000000000
--- a/src/lib/libssl/src/tools/c_info
+++ /dev/null
@@ -1,12 +0,0 @@
1#!/bin/sh
2#
3# print the subject
4#
5
6for i in $*
7do
8 n=`openssl x509 -subject -issuer -enddate -noout -in $i`
9 echo "$i"
10 echo "$n"
11 echo "--------"
12done
diff --git a/src/lib/libssl/src/tools/c_issuer b/src/lib/libssl/src/tools/c_issuer
deleted file mode 100644
index 55821ab740..0000000000
--- a/src/lib/libssl/src/tools/c_issuer
+++ /dev/null
@@ -1,10 +0,0 @@
1#!/bin/sh
2#
3# print out the issuer
4#
5
6for i in $*
7do
8 n=`openssl x509 -issuer -noout -in $i`
9 echo "$i $n"
10done
diff --git a/src/lib/libssl/src/tools/c_name b/src/lib/libssl/src/tools/c_name
deleted file mode 100644
index 28800c0b30..0000000000
--- a/src/lib/libssl/src/tools/c_name
+++ /dev/null
@@ -1,10 +0,0 @@
1#!/bin/sh
2#
3# print the subject
4#
5
6for i in $*
7do
8 n=`openssl x509 -subject -noout -in $i`
9 echo "$i $n"
10done
diff --git a/src/lib/libssl/src/tools/c_rehash.in b/src/lib/libssl/src/tools/c_rehash.in
deleted file mode 100644
index bfc4a69ed4..0000000000
--- a/src/lib/libssl/src/tools/c_rehash.in
+++ /dev/null
@@ -1,180 +0,0 @@
1#!/usr/local/bin/perl
2
3
4# Perl c_rehash script, scan all files in a directory
5# and add symbolic links to their hash values.
6
7my $openssl;
8
9my $dir;
10my $prefix;
11
12if(defined $ENV{OPENSSL}) {
13 $openssl = $ENV{OPENSSL};
14} else {
15 $openssl = "openssl";
16 $ENV{OPENSSL} = $openssl;
17}
18
19my $pwd;
20eval "require Cwd";
21if (defined(&Cwd::getcwd)) {
22 $pwd=Cwd::getcwd();
23} else {
24 $pwd=`pwd`; chomp($pwd);
25}
26my $path_delim = ($pwd =~ /^[a-z]\:/i) ? ';' : ':'; # DOS/Win32 or Unix delimiter?
27
28$ENV{PATH} = "$prefix/bin" . ($ENV{PATH} ? $path_delim . $ENV{PATH} : ""); # prefix our path
29
30if(! -x $openssl) {
31 my $found = 0;
32 foreach (split /$path_delim/, $ENV{PATH}) {
33 if(-x "$_/$openssl") {
34 $found = 1;
35 $openssl = "$_/$openssl";
36 last;
37 }
38 }
39 if($found == 0) {
40 print STDERR "c_rehash: rehashing skipped ('openssl' program not available)\n";
41 exit 0;
42 }
43}
44
45if(@ARGV) {
46 @dirlist = @ARGV;
47} elsif($ENV{SSL_CERT_DIR}) {
48 @dirlist = split /$path_delim/, $ENV{SSL_CERT_DIR};
49} else {
50 $dirlist[0] = "$dir/certs";
51}
52
53if (-d $dirlist[0]) {
54 chdir $dirlist[0];
55 $openssl="$pwd/$openssl" if (!-x $openssl);
56 chdir $pwd;
57}
58
59foreach (@dirlist) {
60 if(-d $_ and -w $_) {
61 hash_dir($_);
62 }
63}
64
65sub hash_dir {
66 my %hashlist;
67 print "Doing $_[0]\n";
68 chdir $_[0];
69 opendir(DIR, ".");
70 my @flist = readdir(DIR);
71 # Delete any existing symbolic links
72 foreach (grep {/^[\da-f]+\.r{0,1}\d+$/} @flist) {
73 if(-l $_) {
74 unlink $_;
75 }
76 }
77 closedir DIR;
78 FILE: foreach $fname (grep {/\.pem$/} @flist) {
79 # Check to see if certificates and/or CRLs present.
80 my ($cert, $crl) = check_file($fname);
81 if(!$cert && !$crl) {
82 print STDERR "WARNING: $fname does not contain a certificate or CRL: skipping\n";
83 next;
84 }
85 link_hash_cert($fname) if($cert);
86 link_hash_crl($fname) if($crl);
87 }
88}
89
90sub check_file {
91 my ($is_cert, $is_crl) = (0,0);
92 my $fname = $_[0];
93 open IN, $fname;
94 while(<IN>) {
95 if(/^-----BEGIN (.*)-----/) {
96 my $hdr = $1;
97 if($hdr =~ /^(X509 |TRUSTED |)CERTIFICATE$/) {
98 $is_cert = 1;
99 last if($is_crl);
100 } elsif($hdr eq "X509 CRL") {
101 $is_crl = 1;
102 last if($is_cert);
103 }
104 }
105 }
106 close IN;
107 return ($is_cert, $is_crl);
108}
109
110
111# Link a certificate to its subject name hash value, each hash is of
112# the form <hash>.<n> where n is an integer. If the hash value already exists
113# then we need to up the value of n, unless its a duplicate in which
114# case we skip the link. We check for duplicates by comparing the
115# certificate fingerprints
116
117sub link_hash_cert {
118 my $fname = $_[0];
119 $fname =~ s/'/'\\''/g;
120 my ($hash, $fprint) = `"$openssl" x509 -hash -fingerprint -noout -in "$fname"`;
121 chomp $hash;
122 chomp $fprint;
123 $fprint =~ s/^.*=//;
124 $fprint =~ tr/://d;
125 my $suffix = 0;
126 # Search for an unused hash filename
127 while(exists $hashlist{"$hash.$suffix"}) {
128 # Hash matches: if fingerprint matches its a duplicate cert
129 if($hashlist{"$hash.$suffix"} eq $fprint) {
130 print STDERR "WARNING: Skipping duplicate certificate $fname\n";
131 return;
132 }
133 $suffix++;
134 }
135 $hash .= ".$suffix";
136 print "$fname => $hash\n";
137 $symlink_exists=eval {symlink("",""); 1};
138 if ($symlink_exists) {
139 symlink $fname, $hash;
140 } else {
141 open IN,"<$fname" or die "can't open $fname for read";
142 open OUT,">$hash" or die "can't open $hash for write";
143 print OUT <IN>; # does the job for small text files
144 close OUT;
145 close IN;
146 }
147 $hashlist{$hash} = $fprint;
148}
149
150# Same as above except for a CRL. CRL links are of the form <hash>.r<n>
151
152sub link_hash_crl {
153 my $fname = $_[0];
154 $fname =~ s/'/'\\''/g;
155 my ($hash, $fprint) = `"$openssl" crl -hash -fingerprint -noout -in '$fname'`;
156 chomp $hash;
157 chomp $fprint;
158 $fprint =~ s/^.*=//;
159 $fprint =~ tr/://d;
160 my $suffix = 0;
161 # Search for an unused hash filename
162 while(exists $hashlist{"$hash.r$suffix"}) {
163 # Hash matches: if fingerprint matches its a duplicate cert
164 if($hashlist{"$hash.r$suffix"} eq $fprint) {
165 print STDERR "WARNING: Skipping duplicate CRL $fname\n";
166 return;
167 }
168 $suffix++;
169 }
170 $hash .= ".r$suffix";
171 print "$fname => $hash\n";
172 $symlink_exists=eval {symlink("",""); 1};
173 if ($symlink_exists) {
174 symlink $fname, $hash;
175 } else {
176 system ("cp", $fname, $hash);
177 }
178 $hashlist{$hash} = $fprint;
179}
180