xref: /openbsd-src/share/man/man8/ssl.8 (revision 2badd5e3f47d2d4252969cd98d7042b4e701b5ac)
1.\"	$OpenBSD: ssl.8,v 1.34 2001/08/17 11:13:58 mpech Exp $
2.\"
3.Dd March 15, 1999
4.Dt SSL 8
5.Os
6.Sh NAME
7.Nm ssl
8.Nd details for libssl and libcrypto
9.Sh DESCRIPTION
10This document describes some of the issues relating to the use of
11the OpenSSL libssl and libcrypto libraries.
12This document is intended as an overview of what the libraries do,
13and what uses them.
14.Pp
15The SSL libraries (libssl and libcrypto) implement the
16.Ar SSL version 2 ,
17.Ar SSL version 3 ,
18and
19.Ar TLS version 1
20protocols.
21.Ar SSL version 2
22and
23.Ar 3
24are most
25commonly used by the
26.Ar https
27protocol for encrypted web transactions, as can be done with
28.Xr httpd 8 .
29The libcrypto library is also used by various programs such as
30.Xr ssh 1 ,
31.Xr sshd 8 ,
32and
33.Xr isakmpd 8 .
34.Sh RANDOM DATA SOURCE
35.Ox
36uses the
37.Xr arandom 4
38device as the default source for random data when needed by the routines in
39libcrypto and libssl.
40If the
41.Xr arandom 4
42device does not exist or is not readable, many of the routines will fail.
43This is most commonly seen by users as the
44.Ar RSA
45routines failing in applications such as
46.Xr ssh 1 ,
47and
48.Xr httpd 8 .
49.Pp
50It is important to remember when using a random data source for certificate
51and key generation that the random data source should not be visible by
52people who could duplicate the process and come up with the same result.
53You should ensure that nobody who you don't trust is in a position to read
54the same random data used by you to generate keys and certificates.
55The
56.Xr arandom 4
57device ensures that no two users on the same machine will see the same
58data.
59See
60.Xr openssl 1
61for more information on how to use different sources of random data.
62.Sh SERVER CERTIFICATES
63The most common uses of
64.Ar SSL/TLS
65will require you to generate a server certificate, which is provided by your
66host as evidence of its identity when clients make new connections.
67The certificates reside in the
68.Pa /etc/ssl
69directory, with the keys in the
70.Pa /etc/ssl/private
71directory.
72.Pp
73Private keys can be encrypted using
74.Ar 3DES
75and a passphrase to protect their integrity should the encrypted file
76be disclosed, However it is
77important to note that encrypted server keys mean that the passphrase
78needs to be typed in every time the server is started.
79If a passphrase is not used, you will need to be absolutely sure your
80key file is kept secure.
81.Sh GENERATING DSA SERVER CERTIFICATES
82Generating a
83.Ar DSA
84certificate involves several steps.
85First, you generate a
86.Ar DSA
87parameter set with a command like the following:
88.Bd -literal -offset indent
89# openssl dsaparam 1024 -out dsa1024.pem
90.Ed
91.Pp
92Would generate
93.Ar DSA
94parameters for 1024 bit
95.Ar DSA
96keys, and save them to the
97file
98.Pa dsa1024.pem .
99.Pp
100Once you have the
101.Ar DSA
102parameters generated, you can generate a certificate
103and unencrypted private key using the command:
104.Bd -literal -offset indent
105# openssl req -x509 -nodes -newkey dsa:dsa1024.pem \\
106  -out /etc/ssl/dsacert.pem -keyout /etc/ssl/private/dsakey.pem
107.Ed
108.Pp
109To generate an encrypted private key, you would use:
110.Bd -literal -offset indent
111# openssl req -x509 -newkey dsa:dsa1024.pem \\
112  -out /etc/ssl/dsacert.pem -keyout /etc/ssl/private/dsakey.pem
113.Ed
114.Sh GENERATING RSA SERVER CERTIFICATES FOR WEB SERVERS
115To support
116.Ar https
117transactions in
118.Xr httpd 8
119you will need to generate an
120.Ar RSA
121certificate.
122.Bd -literal -offset indent
123# openssl genrsa -out /etc/ssl/private/server.key 1024
124.Ed
125.Pp
126Or, if you wish the key to be encrypted with a passphrase that you will
127have to type in when starting servers
128.Bd -literal -offset indent
129# openssl genrsa -des3 -out /etc/ssl/private/server.key 1024
130.Ed
131.Pp
132The next step is to generate a
133.Ar Certificate Signing Request
134which is used
135to get a
136.Ar Certifying Authority (CA)
137to sign your certificate.
138To do this use the command:
139.Bd -literal -offset indent
140# openssl req -new -key /etc/ssl/private/server.key \\
141  -out /etc/ssl/private/server.csr
142.Ed
143.Pp
144This
145.Pa server.csr
146file can then be given to
147.Ar Certifying Authority
148who will sign the key.
149One such CA is
150.Ar Thawte Certification
151which you can reach at
152.Ar http://www.thawte.com/.
153Thawte can currently sign RSA keys for you.
154A procedure is being worked out to allow for DSA keys.
155.Pp
156You can also sign the key yourself, using the command:
157.Bd -literal -offset indent
158# openssl x509 -req -days 365 -in /etc/ssl/private/server.csr \\
159  -signkey /etc/ssl/private/server.key -out /etc/ssl/server.crt
160.Ed
161.Pp
162With
163.Pa /etc/ssl/server.crt
164and
165.Pa /etc/ssl/private/server.key
166in place, you should be able to start
167.Xr httpd 8
168with the
169.Ar -DSSL
170flag, enabling
171.Ar https
172transactions with your machine on port 443.
173.Pp
174You will most likely want to generate a self-signed certificate in the
175manner above along with your certificate signing request to test your
176server's functionality even if you are going to have the certificate
177signed by another Certifying Authority.  Once your Certifying
178Authority returns the signed certificate to you, you can switch to
179using the new certificate by replacing the self-signed
180.Pa /etc/ssl/server.crt
181with the certificate signed by your Certifying Authority, and then
182restarting
183.Xr httpd 8
184.Sh BUGS
185The world needs more
186.Ar DSA
187capable
188.Ar SSL
189and
190.Ar SSH
191services.
192.Sh SEE ALSO
193.Xr httpd 8 ,
194.Xr ssh 1 ,
195.Xr sshd 8 ,
196.Xr isakmpd 8 ,
197.Xr pkg_add 1 ,
198.Xr openssl 1 ,
199.Xr arandom 4 ,
200.Xr ssl 3 ,
201.Xr rc 8
202.Sh HISTORY
203Prior to Sept 21, 2000
204there were problems shipping fully functional implementations of these
205protocols everywhere in the world, as such shipment would include shipping
206.Ar into
207the United States, thus causing problems.
208.Ar RSA Data Security Inc (RSADSI)
209held the patent on the
210.Ar RSA
211algorithm in the United States.
212Because of this, free implementations of
213.Ar RSA
214were difficult to distribute and propagate.
215(The
216.Ar RSA
217patent was probably more effective at preventing the late adoption of
218widespread international integrated crypto than the much maligned
219ITAR restrictions were).
220Prior to
221.Ox 2.8 ,
222these libraries shipped without the
223.Ar RSA
224algorithm -- all such functions
225were stubbed to fail.
226Since
227.Ar RSA
228is a key component of
229.Ar SSL version 2 ,
230this
231meant that
232.Ar SSL version 2
233would not work at all.
234.Ar SSL version 3
235and
236.Ar TLS version 1
237allow for the exchange of keys via mechanisms that do not
238involve
239.Ar RSA ,
240and would work with the shipped version of the libraries,
241assuming both ends could agree to a cipher suite and key exchange that
242did not involve RSA.
243Likewise, the SSH1 protocol in
244.Xr ssh 1
245uses RSA, so it was similarly encumbered.
246.Pp
247For instance, another typical alternative
248is
249.Ar DSA ,
250which is not encumbered by commercial patents (and lawyers).
251.Pp
252The
253.Ar https
254protocol used by web browsers (in modern incarnations),
255allows for the use of
256.Ar SSL version 3
257and
258.Ar TLS version 1 ,
259which in theory allows for encrypted web transactions without using
260.Ar RSA .
261Unfortunately all the popular web browsers
262buy their cryptographic code from
263.Ar RSADSI .
264Predictably,
265.Ar RSADSI
266would prefer if web browsers used their patented algorithm, and thus their
267libraries do not implement any
268.Ar non-RSA
269cipher and keying combination.
270The result of this was that while the
271.Ar https
272protocol allowed for many cipher suites that did not require the use
273of patented algorithms, It was very difficult to use these with the
274popular commercially available software.
275Prior to version 2.8,
276.Ox
277allowed users to download
278.Ar RSA
279enabled versions of the shared libssl and libcrypto libraries
280which allowed users to enable full function without recompiling
281the applications.
282This method is now no longer needed, as the fully functional
283libraries ship with the system.
284However, this entire debacle is worth remembering when choosing
285software and vendors.
286.Pp
287This document first appeared in
288.Ox 2.5 .
289