1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE chapter SYSTEM "chapter.dtd">
7
<year>2003</year><year>2009</year>
8
<holder>Ericsson AB. All Rights Reserved.</holder>
11
The contents of this file are subject to the Erlang Public License,
12
Version 1.1, (the "License"); you may not use this file except in
13
compliance with the License. You should have received a copy of the
14
Erlang Public License along with this software. If not, it can be
15
retrieved online at http://www.erlang.org/.
17
Software distributed under the License is distributed on an "AS IS"
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
the License for the specific language governing rights and limitations
24
<title>Creating Certificates</title>
25
<prepared>UAB/F/P Peter Högfeldt</prepared>
27
<date>2003-06-16</date>
29
<file>create_certs.sgml</file>
31
<p>Here we consider the creation of example certificates.
35
<title>The openssl Command</title>
36
<p>The <c>openssl</c> command is a utility that comes with the
37
OpenSSL distribution. It provides a variety of subcommands. Each
38
subcommand is invoked as</p>
39
<code type="none"><![CDATA[
40
openssl subcmd <options and arguments> ]]></code>
41
<p>where <c>subcmd</c> denotes the subcommand in question.
43
<p>We shall use the following subcommands to create certificates for
44
the purpose of testing Erlang/OTP SSL:
46
<list type="bulleted">
47
<item><em>req</em> to create certificate requests and a
48
self-signed certificates,
50
<item><em>ca</em> to create certificates from certificate requests.</item>
52
<p>We create the following certificates:
54
<list type="bulleted">
55
<item>the <em>erlangCA</em> root certificate (a self-signed
57
<item>the <em>otpCA</em> certificate signed by the <em>erlangCA</em>, </item>
58
<item>a client certificate signed by the <em>otpCA</em>, and</item>
59
<item>a server certificate signed by the <em>otpCA</em>.</item>
63
<title>The openssl configuration file</title>
64
<p>An <c>openssl</c> configuration file consist of a number of
65
sections, where each section starts with one line containing
66
<c>[ section_name ]</c>, where <c>section_name</c> is the name
67
of the section. The first section of the file is either
68
unnamed, or is named <c>[ default ]</c>. For further details
69
see the OpenSSL config(5) manual page.
71
<p>The required sections for the subcommands we are going to
76
<cell align="left" valign="middle">subcommand</cell>
77
<cell align="left" valign="middle">required/default section</cell>
78
<cell align="left" valign="middle">override command line option</cell>
79
<cell align="left" valign="middle">configuration file option</cell>
82
<cell align="left" valign="middle">req</cell>
83
<cell align="left" valign="middle">[req]</cell>
84
<cell align="left" valign="middle">-</cell>
85
<cell align="left" valign="middle"><c>-config FILE</c></cell>
88
<cell align="left" valign="middle">ca</cell>
89
<cell align="left" valign="middle">[ca]</cell>
90
<cell align="left" valign="middle"><c>-name section</c></cell>
91
<cell align="left" valign="middle"><c>-config FILE</c></cell>
93
<tcaption>openssl subcommands to use</tcaption>
98
<title>Creating the Erlang root CA</title>
99
<p>The Erlang root CA is created with the command</p>
101
\011openssl req -new -x509 -config /some/path/req.cnf \\
102
\011 -keyout /some/path/key.pem -out /some/path/cert.pem </code>
103
<p>where the option <c>-new</c> indicates that we want to create
104
a new certificate request and the option <c>-x509</c> implies
105
that a self-signed certificate is created.
110
<title>Creating the OTP CA</title>
111
<p>The OTP CA is created by first creating a certificate request
114
\011openssl req -new -config /some/path/req.cnf \\
115
\011 -keyout /some/path/key.pem -out /some/path/req.pem </code>
116
<p>and the ask the Erlang CA to sign it:</p>
118
\011openssl ca -batch -notext -config /some/path/req.cnf \\
119
\011 -extensions ca_cert -in /some/path/req.pem -out /some/path/cert.pem </code>
120
<p>where the option <c>-extensions</c> refers to a section in the
121
configuration file saying that it should create a CA certificate,
122
and not a plain user certificate.
124
<p>The <c>client</c> and <c>server</c> certificates are created
125
similarly, except that the option <c>-extensions</c> then has the
126
value <c>user_cert</c>.
132
<title>An Example</title>
133
<p>The following module <c>create_certs</c> is used by the Erlang/OTP
134
SSL application for generating certificates to be used in tests. The
135
source code is also found in <c>ssl-X.Y.Z/examples/certs/src</c>.
137
<p>The purpose of the <c>create_certs:all/1</c> function is to make
138
it possible to provide from the <c>erl</c> command line, the
139
full path name of the <c>openssl</c> command.
141
<p>Note that the module creates temporary OpenSSL configuration files
142
for the <c>req</c> and <c>ca</c> subcommands.
144
<codeinclude file="../../examples/certs/src/make_certs.erl" tag="" type="erl"></codeinclude>