From 5b0a4180582921fe3b61b430f0c87d9a68ba6da8 Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin This chapter describes how the Erlang distribution can use
SSL to get additional verification and security.
-
- Note this
- documentation is written for the old ssl implementation and
- will be updated for the new one once this functionality is
- supported by the new implementation. The Erlang distribution can in theory use almost any connection
based protocol as bearer. A module that implements the protocol
- specific parts of connection setup is however needed. The
+ specific parts of the connection setup is however needed. The
default distribution module is In the SSL application there is an additional distribution
- module, In the SSL application there is an additional distribution
+ module, The security depends on how the connections are set up, one can
- use key files or certificates to just get a encrypted
- connection. One can also make the SSL package verify the
- certificates of other nodes to get additional security.
- Cookies are however always used as they can be used to
- differentiate between two different Erlang networks. The security level depends on the parameters provided to the
+ SSL connection setup. Erlang node cookies are however always
+ used, as they can be used to differentiate between two different
+ Erlang networks. Setting up Erlang distribution over SSL involves some simple but
necessary steps:
+
+
The simplest boot script possible includes only the Kernel + +
The simplest boot script possible includes only the Kernel
and STDLIB applications. Such a script is located in the
Erlang distributions bin directory. The source for the script
can be found under the Erlang installation top directory under
-
An example .rel file with SSL added may look like this:
+
-{release, {"OTP APN 181 01","P7A"}, {erts, "5.0"},
- [{kernel,"2.5"},
- {stdlib,"1.8.1"},
- {ssl,"2.2.1"}]}.
- Note that the version numbers surely will differ in your system. - Whenever one of the applications included in the script is - upgraded, the script has to be changed.
-Assuming the above .rel file is stored in a file
-
-1> systools:make_script("start_ssl",[]).
- There will now be a file
+
+ Note that the version numbers surely will differ in your system.
+ Whenever one of the applications included in the script is
+ upgraded, the script has to be changed.
+ Assuming the above .rel file is stored in a file
+ start_ssl.rel in the current directory, a boot script
+ can be built like this:
+
+
+ 1> systools:make_script("start_ssl",[]).
+
+ There will now be a file start_ssl.boot in the current
+ directory. To test the boot script, start Erlang with the
+ -boot command line parameter specifying this boot script
+ (with its full path but without the .boot suffix), in
+ Unix it could look like this:
+
+
+ whereis(ssl_server).
-<0.32.0> ]]>
+1> whereis(ssl_manager).
+<0.41.0> ]]>
The
As an alternative to building a bootscript, one can explicitly
- add the path to the ssl
As an alternative to building a bootscript, one can explicitly
+ add the path to the SSL
Note that the clone of the SSL application is necessary to + enable the use of the SSL code in such an early bootstage as + needed to setup the distribution, however this will make it + impossible to soft upgrade the SSL application.
The distribution module for SSL is named
The distribution module for SSL is named
Extending the command line from above gives us the following:
-$ erl -boot /home/me/ssl/start_ssl -proto_dist inet_ssl
- For the distribution to actually be started, we need to give - the emulator a name as well:
+$ erl -boot /home/me/ssl/start_ssl -proto_dist inet_tls + +For the distribution to actually be started, we need to give +the emulator a name as well:
-$ erl -boot /home/me/ssl/start_ssl -proto_dist inet_ssl -sname ssl_test
+$ erl -boot /home/me/ssl/start_ssl -proto_dist inet_tls -sname ssl_test
Erlang (BEAM) emulator version 5.0 [source]
Eshell V5.0 (abort with ^G)
(ssl_test@myhost)1>
Note however that a node started in this way will refuse to talk - to other nodes, as no certificates or key files are supplied + to other nodes, as no ssl parameters are supplied (see below).
-When the SSL distribution starts, the OTP system is in its
- early boot stage, why neither
For SSL to work, you either need certificate files or a - key file. Certificate files can be specified both when working as - client and as server (connecting or accepting).
- +For SSL to work, at least + a public key and certificate needs to be specified for the server + side. In the following example the PEM-files consists of two + entries the servers certificate and its private key.
+On the
The command line argument for specifying the SSL options is named
-
An example command line would now look something like this + SSL distribution will add when creating a socket.
+ +One can specify the simpler SSL options certfile, keyfile,
+ password, cacertfile, verify, reuse_sessions,
+ secure_renegotiation, depth, hibernate_after and ciphers (use old
+ string format) by adding the prefix server_ or client_ to the
+ option name. The server can also take the options dhfile and
+ fail_if_no_peer_cert (also prefixed).
+
More complex options such as verify_fun are not available at + the moment but a mechanism to handle such options may be added in + a future release.
+ +Raw socket options such as packet and size must not be specified on + the command line
. + +The command line argument for specifying the SSL options is named
+
An example command line would now look something like this (line breaks in the command are for readability, they should not be there when typed):
-$ erl -boot /home/me/ssl/start_ssl -proto_dist inet_ssl
- -ssl_dist_opt client_certfile "/home/me/ssl/erlclient.pem"
+$ erl -boot /home/me/ssl/start_ssl -proto_dist inet_tls
-ssl_dist_opt server_certfile "/home/me/ssl/erlserver.pem"
- -ssl_dist_opt verify 1 depth 1
+ -ssl_dist_opt server_secure_renegotiation true client_secure_renegotiate true
-sname ssl_test
Erlang (BEAM) emulator version 5.0 [source]
@@ -211,12 +220,11 @@ Eshell V5.0 (abort with ^G)
subsequent invocations of Erlang.
In a Unix (Bourne) shell it could look like this (line breaks for
- readability):
+ readability, they should not be there when typed):
-$ ERL_FLAGS="-boot \\"/home/me/ssl/start_ssl\\" -proto_dist inet_ssl
- -ssl_dist_opt client_certfile \\"/home/me/ssl/erlclient.pem\\"
- -ssl_dist_opt server_certfile \\"/home/me/ssl/erlserver.pem\\"
- -ssl_dist_opt verify 1 -ssl_dist_opt depth 1"
+$ ERL_FLAGS="-boot /home/me/ssl/start_ssl -proto_dist inet_tls
+ -ssl_dist_opt server_certfile /home/me/ssl/erlserver.pem
+ -ssl_dist_opt server_secure_renegotiation true client_secure_renegotiate true"
$ export ERL_FLAGS
$ erl -sname ssl_test
Erlang (BEAM) emulator version 5.0 [source]
@@ -227,15 +235,12 @@ Eshell V5.0 (abort with ^G)
{progname,["erl "]},
{sname,["ssl_test"]},
{boot,["/home/me/ssl/start_ssl"]},
- {proto_dist,["inet_ssl"]},
- {ssl_dist_opt,["client_certfile","/home/me/ssl/erlclient.pem"]},
+ {proto_dist,["inet_tls"]},
{ssl_dist_opt,["server_certfile","/home/me/ssl/erlserver.pem"]},
- {ssl_dist_opt,["verify","1"]},
- {ssl_dist_opt,["depth","1"]},
+ {ssl_dist_opt,["server_secure_renegotiation","true",
+ "client_secure_renegotiate","true"]
{home,["/home/me"]}]
The init:get_arguments() call verifies that the correct
arguments are supplied to the emulator.
The erlang ssl application currently supports SSL 3.0 and TLS 1.0 +
The erlang SSL application currently supports SSL 3.0 and TLS 1.0 RFC 2246, and will in the future also support later versions of TLS. SSL 2.0 is not supported.
-By default erlang ssl is run over the TCP/IP protocol even +
By default erlang SSL is run over the TCP/IP protocol even though you could plug in any other reliable transport protocol with the same API as gen_tcp.
If a client and server wants to use an upgrade mechanism, such as - defined by RFC2817, to upgrade a regular TCP/IP connection to an ssl - connection the erlang ssl API supports this. This can be useful for + defined by RFC2817, to upgrade a regular TCP/IP connection to an SSL + connection the erlang SSL API supports this. This can be useful for things such as supporting HTTP and HTTPS on the same port and implementing virtual hosting.
@@ -131,7 +131,7 @@ connections. Sessions are used to avoid the expensive negotiation of new security parameters for each connection." -Session data is by default kept by the ssl application in a +
Session data is by default kept by the SSL application in a memory storage hence session data will be lost at application restart or takeover. Users may define their own callback module to handle session data storage if persistent data storage is @@ -140,8 +140,8 @@ possible to configure the amount of time the session data should be saved.
-Ssl clients will by default try to reuse an available session, - ssl servers will by default agree to reuse sessions when clients +
SSL clients will by default try to reuse an available session, + SSL servers will by default agree to reuse sessions when clients ask to do so.
-- cgit v1.2.3