Renamed many classes and feature to use "secure" term instead of "ssl". (note, the .ecf are still using the "ssl" terminologie).

Provided easy way to set secure settings for Standalone.
For wsf launcher boolean option accept "true" or "yes" for True boolean, anything else is False.
This commit is contained in:
2016-10-14 11:52:48 +02:00
parent 01a9d02586
commit d4ec640ac8
47 changed files with 483 additions and 298 deletions

View File

@@ -40,12 +40,12 @@ feature {NONE} -- Internal
then
l_socket := l_persistent_connection.socket
if a_is_https then
if attached {HTTP_STREAM_SSL_SOCKET} l_socket as l_ssl_socket then
if attached {HTTP_STREAM_SECURE_SOCKET} l_socket as l_ssl_socket then
Result := l_ssl_socket
else
l_socket := Void
end
elseif attached {HTTP_STREAM_SSL_SOCKET} l_socket as l_ssl_socket then
elseif attached {HTTP_STREAM_SECURE_SOCKET} l_socket as l_ssl_socket then
l_socket := Void
end
if l_socket /= Void and then not l_socket.is_connected then
@@ -59,7 +59,7 @@ feature {NONE} -- Internal
else
session.set_persistent_connection (Void)
if a_is_https then
create {HTTP_STREAM_SSL_SOCKET} Result.make_client_by_port (a_port, a_host)
create {HTTP_STREAM_SECURE_SOCKET} Result.make_client_by_port (a_port, a_host)
else
create Result.make_client_by_port (a_port, a_host)
end

View File

@@ -22,7 +22,7 @@
</condition>
</external_include>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf" readonly="false"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf">
<condition>
<custom name="ssl_enabled" value="true"/>
@@ -94,6 +94,5 @@
</condition>
</cluster>
</cluster>
</target>
</system>

View File

@@ -41,6 +41,13 @@
<version type="compiler" max="16.11.0.0"/>
</condition>
</file_rule>
<cluster name="disabled_ssl_network" location="$|no_ssl\" recursive="true">
<condition>
<custom name="ssl_enabled" excluded_value="true"/>
<custom name="net_ssl_enabled" excluded_value="true"/>
<custom name="httpd_ssl_enabled" excluded_value="true"/>
</condition>
</cluster>
<cluster name="ssl_network" location="$|ssl\" recursive="true">
<condition>
<custom name="ssl_enabled" value="true"/>

View File

@@ -21,10 +21,12 @@ create {NETWORK_STREAM_SOCKET}
feature -- Status report
is_ssl_supported: BOOLEAN
-- SSL supported?
is_secure_connection_supported: BOOLEAN
-- SSL/TLS supported?
once
Result := False
ensure
Result = {HTTP_SECURE_HELPER}.is_secure_connection_supported
end
feature -- Input

View File

@@ -0,0 +1,18 @@
note
description: "[
Interface helping using SSL.
For now, mainly for `is_secure_connection_supported' to indicate if current project is compiled with SSL support.
i.e compiled with EiffelNet-SSL library.
]"
date: "$Date$"
revision: "$Revision$"
class
HTTP_SECURE_HELPER
feature -- Status
is_secure_connection_supported: BOOLEAN = False
-- Is Current system compiled with EiffelNet-SSL support?
end

View File

@@ -7,7 +7,7 @@ note
revision: "$Revision$"
class
HTTP_STREAM_SSL_SOCKET
HTTP_STREAM_SECURE_SOCKET
inherit
HTTP_STREAM_SOCKET
@@ -17,7 +17,7 @@ create
make_client_by_port, make_client_by_address_and_port,
make_server_by_port, make_server_by_address_and_port, make_loopback_server_by_port
create {HTTP_STREAM_SSL_SOCKET}
create {HTTP_STREAM_SECURE_SOCKET}
make_from_descriptor_and_address
feature -- Element change
@@ -29,9 +29,39 @@ feature -- Element change
set_key_file_path (a_key_filename: PATH)
do
end
feature -- SSL Helpers
set_secure_protocol (v: NATURAL)
do
end
set_secure_protocol_to_ssl_2_or_3
-- Set `ssl_protocol' with `Ssl_23'.
do
end
set_secure_protocol_to_tls_1_0
-- Set `ssl_protocol' with `Tls_1_0'.
do
end
set_secure_protocol_to_tls_1_1
-- Set `ssl_protocol' with `Tls_1_1'.
do
end
set_secure_protocol_to_tls_1_2
-- Set `ssl_protocol' with `Tls_1_2'.
do
end
set_secure_protocol_to_dtls_1_0
-- Set `ssl_protocol' with `Dtls_1_0'.
do
end
invariant
ssl_not_supported: not is_ssl_supported -- Current is a Fake SSL interface!
secure_connection_not_supported: not is_secure_connection_supported -- Current is a Fake SSL interface!
note
copyright: "2011-2013, Javier Velilla, Jocelyn Fiat and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -0,0 +1,18 @@
note
description: "[
Interface helping using SSL.
For now, mainly for `is_secure_connection_supported' to indicate if current project is compiled with SSL support.
i.e compiled with EiffelNet-SSL library.
]"
date: "$Date$"
revision: "$Revision$"
class
HTTP_SECURE_HELPER
feature -- Status
is_secure_connection_supported: BOOLEAN = True
-- Is Current system compiled with EiffelNet-SSL support?
end

View File

@@ -4,7 +4,7 @@ note
revision: "$Revision$"
class
HTTP_STREAM_SSL_SOCKET
HTTP_STREAM_SECURE_SOCKET
inherit
HTTP_STREAM_SOCKET
@@ -20,7 +20,7 @@ inherit
connect, shutdown,
do_accept
redefine
is_ssl_supported,
is_secure_connection_supported,
put_managed_pointer,
read_stream_noexception,
read_into_pointer_noexception,
@@ -32,7 +32,7 @@ inherit
put_managed_pointer -- Redefine to allow support of compiler before 16.11.
end
HTTP_STREAM_SSL_SOCKET_EXT
HTTP_STREAM_SECURE_SOCKET_EXT
create
make, make_empty,
@@ -44,42 +44,44 @@ create {SSL_NETWORK_STREAM_SOCKET}
feature -- Status report
is_ssl_supported: BOOLEAN
is_secure_connection_supported: BOOLEAN = True
-- SSL supported?
once
Result := True
feature -- Secure connection Helpers
set_secure_protocol (v: NATURAL)
do
set_tls_protocol (v)
end
feature -- SSL Helpers
set_ssl_protocol_to_ssl_2_or_3
set_secure_protocol_to_ssl_2_or_3
-- Set `ssl_protocol' with `Ssl_23'.
do
set_tls_protocol ({SSL_PROTOCOL}.Ssl_23)
set_secure_protocol ({SSL_PROTOCOL}.Ssl_23)
end
set_ssl_protocol_to_tls_1_0
set_secure_protocol_to_tls_1_0
-- Set `ssl_protocol' with `Tls_1_0'.
do
set_tls_protocol ({SSL_PROTOCOL}.Tls_1_0)
set_secure_protocol ({SSL_PROTOCOL}.Tls_1_0)
end
set_ssl_protocol_to_tls_1_1
set_secure_protocol_to_tls_1_1
-- Set `ssl_protocol' with `Tls_1_1'.
do
set_tls_protocol ({SSL_PROTOCOL}.Tls_1_1)
set_secure_protocol ({SSL_PROTOCOL}.Tls_1_1)
end
set_ssl_protocol_to_tls_1_2
set_secure_protocol_to_tls_1_2
-- Set `ssl_protocol' with `Tls_1_2'.
do
set_tls_protocol ({SSL_PROTOCOL}.Tls_1_2)
set_secure_protocol ({SSL_PROTOCOL}.Tls_1_2)
end
set_ssl_protocol_to_dtls_1_0
set_secure_protocol_to_dtls_1_0
-- Set `ssl_protocol' with `Dtls_1_0'.
do
set_tls_protocol ({SSL_PROTOCOL}.Dtls_1_0)
set_secure_protocol ({SSL_PROTOCOL}.Dtls_1_0)
end
feature -- Input

View File

@@ -6,7 +6,7 @@ note
]"
deferred class
HTTP_STREAM_SSL_SOCKET_EXT
HTTP_STREAM_SECURE_SOCKET_EXT
feature {NONE} -- SSL bridge

View File

@@ -6,7 +6,7 @@ note
]"
deferred class
HTTP_STREAM_SSL_SOCKET_EXT
HTTP_STREAM_SECURE_SOCKET_EXT
feature {NONE} -- SSL bridge

View File

@@ -20,6 +20,6 @@
<setting name="concurrency" value="thread"/>
</target>
<target name="ws_client_ssl" extends="ws_client">
<variable name="net_ssl_enabled" value="true"/>
<variable name="ssl_enabled" value="true"/>
</target>
</system>

View File

@@ -14,14 +14,14 @@ inherit
feature -- Status report
is_ssl_supported: BOOLEAN = False
is_secure_connection_supported: BOOLEAN = False
feature -- Factory
new_socket (a_port: INTEGER; a_host: STRING): HTTP_STREAM_SOCKET
do
if is_tunneled then
check ssl_supported: False end
if is_secure then
check is_secure_connection_supported: False end
end
create {HTTP_STREAM_SOCKET} Result.make_client_by_port (a_port, a_host)
end

View File

@@ -14,37 +14,37 @@ inherit
feature -- Status report
is_ssl_supported: BOOLEAN = True
is_secure_connection_supported: BOOLEAN = True
feature -- Factory
new_socket (a_port: INTEGER; a_host: STRING): HTTP_STREAM_SOCKET
local
l_ssl: HTTP_STREAM_SSL_SOCKET
l_secure: HTTP_STREAM_SECURE_SOCKET
do
if is_tunneled then
create l_ssl.make_client_by_port (a_port, a_host)
Result := l_ssl
if attached ssl_protocol as l_prot then
if is_secure then
create l_secure.make_client_by_port (a_port, a_host)
Result := l_secure
if attached secure_protocol as l_prot then
if l_prot.is_case_insensitive_equal ("ssl_2_3") then
l_ssl.set_ssl_protocol_to_ssl_2_or_3
l_secure.set_secure_protocol_to_ssl_2_or_3
elseif l_prot.is_case_insensitive_equal ("tls_1_0") then
l_ssl.set_ssl_protocol_to_tls_1_0
l_secure.set_secure_protocol_to_tls_1_0
elseif l_prot.is_case_insensitive_equal ("tls_1_1") then
l_ssl.set_ssl_protocol_to_tls_1_1
l_secure.set_secure_protocol_to_tls_1_1
elseif l_prot.is_case_insensitive_equal ("tls_1_2") then
l_ssl.set_ssl_protocol_to_tls_1_2
l_secure.set_secure_protocol_to_tls_1_2
elseif l_prot.is_case_insensitive_equal ("dtls_1_0") then
l_ssl.set_ssl_protocol_to_dtls_1_0
l_secure.set_secure_protocol_to_dtls_1_0
else -- Default
l_ssl.set_ssl_protocol_to_tls_1_2
l_secure.set_secure_protocol_to_tls_1_2
end
end
if attached ssl_key_file as k then
l_ssl.set_key_file_path (k)
if attached secure_certificate_file as c then
l_secure.set_certificate_file_path (c)
end
if attached ssl_certificate_file as c then
l_ssl.set_certificate_file_path (c)
if attached secure_certificate_key_file as k then
l_secure.set_key_file_path (k)
end
else
create {HTTP_STREAM_SOCKET} Result.make_client_by_port (a_port, a_host)

View File

@@ -11,7 +11,6 @@ deferred class
WEB_SOCKET
inherit
WEB_SOCKET_CONSTANTS
feature -- Access
@@ -37,7 +36,7 @@ feature -- Access
-- Has the result fo protocol negotiation between client and the server
-- By default it's an empty string.
is_tunneled: BOOLEAN
is_secure: BOOLEAN
-- Is the current connection tunneled over TLS/SSL?
local
l_uri: STRING

View File

@@ -10,7 +10,6 @@ deferred class
WEB_SOCKET_CLIENT_I
inherit
WEB_SOCKET_SUBSCRIBER
redefine
on_websocket_error,
@@ -106,39 +105,39 @@ feature -- Access
server_handshake: WEB_SOCKET_HANDSHAKE_DATA
-- Handshake data received from the server
feature -- Access: ssl
feature -- Access: secure
is_ssl_supported: BOOLEAN
is_secure_connection_supported: BOOLEAN
-- Is SSL supported?
deferred
end
ssl_protocol: detachable READABLE_STRING_GENERAL
-- SSL protocol , if `is_ssl_supported'.
secure_protocol: detachable READABLE_STRING_GENERAL
-- SSL protocol , if `is_secure_connection_supported'.
ssl_certificate_file: detachable PATH
-- SSL certificate file , if `is_ssl_supported'.
secure_certificate_file: detachable PATH
-- SSL certificate file , if `is_secure_connection_supported'.
ssl_key_file: detachable PATH
-- SSL key file , if `is_ssl_supported'.
secure_certificate_key_file: detachable PATH
-- SSL key file , if `is_secure_connection_supported'.
feature -- Element change
set_ssl_protocol (a_prot: like ssl_protocol)
set_secure_protocol (a_prot: like secure_protocol)
do
ssl_protocol := a_prot
secure_protocol := a_prot
end
set_ssl_certificate_file (p: detachable PATH)
set_secure_certificate_file (p: detachable PATH)
-- Set SSL certificate from file at `p'.
do
ssl_certificate_file := p
secure_certificate_file := p
end
set_ssl_key_file (p: detachable PATH)
set_secure_certificate_key_file (p: detachable PATH)
-- Set SSL key from file at `p'.
do
ssl_key_file := p
secure_certificate_key_file := p
end
feature -- Events API
@@ -346,7 +345,7 @@ feature {NONE} -- Implementation
set_default_port
do
if is_tunneled then
if is_secure then
port := wss_port_default
else
port := ws_port_default

View File

@@ -27,8 +27,8 @@ feature {NONE} -- Initialization
create ready_state.make
ensure
uri_set: a_uri = uri
port_wss: is_tunneled implies port = wss_port_default
port_ws: not is_tunneled implies port = ws_port_default
port_wss: is_secure implies port = wss_port_default
port_ws: not is_secure implies port = ws_port_default
ready_state_set: ready_state.state = {WEB_SOCKET_READY_STATE}.connecting
subscriber_set: subscriber = a_subscriber
protocol_set: protocol.is_empty
@@ -58,8 +58,8 @@ feature {NONE} -- Initialization
create ready_state.make
ensure
uri_set: a_uri = uri
port_wss: is_tunneled implies port = wss_port_default
port_ws: not is_tunneled implies port = ws_port_default
port_wss: is_secure implies port = wss_port_default
port_ws: not is_secure implies port = ws_port_default
protocols_set: protocols = a_protocols
ready_state_set: ready_state.state = {WEB_SOCKET_READY_STATE}.connecting
subscriber_set: subscriber = a_subscriber
@@ -214,7 +214,7 @@ feature {NONE} -- Implementation
set_default_port
do
if is_tunneled then
if is_secure then
port := wss_port_default
else
port := ws_port_default

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="web_socket_client" uuid="934F36F1-D417-4695-A5A9-2D005B35BB1B" library_target="web_socket_client">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="web_socket_client" uuid="EE010507-597F-4FAD-8EFA-B7251E800911" library_target="web_socket_client">
<target name="web_socket_client">
<root all_classes="true"/>
<file_rule>
@@ -16,47 +16,28 @@
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl.ecf">
<condition>
<custom name="client_ssl_disabled" excluded_value="true"/>
</condition>
</library>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
<library name="uri" location="$ISE_LIBRARY\library\text\uri\uri.ecf"/>
<library name="lib_http_network" location="..\..\http_network\http_network.ecf"/>
<library name="lib_web_socket_protocol" location="..\protocol\web_socket_protocol.ecf"/>
<cluster name="web_socket_client" location=".\src\" recursive="true">
<file_rule>
<exclude>/socket$</exclude>
<exclude>/no_ssl$</exclude>
<exclude>/ssl$</exclude>
<exclude>/spec$</exclude>
</file_rule>
<cluster name="ssl" location="$|ssl\" recursive="true">
<condition>
<custom name="client_ssl_disabled" excluded_value="true"/>
<custom name="ssl_enabled" value="true"/>
</condition>
<condition>
<custom name="net_ssl_enabled" value="true"/>
</condition>
</cluster>
<cluster name="no_ssl" location="$|no_ssl\" recursive="true">
<condition>
<custom name="client_ssl_disabled" value="true"/>
</condition>
</cluster>
<cluster name="socket" location="$|socket\">
<file_rule>
<exclude>/tcp_stream_socket.e$</exclude>
<condition>
<version type="compiler" max="15.2.0.0"/>
</condition>
</file_rule>
<cluster name="socket_ssl" location="$|ssl\" recursive="true" hidden="true">
<condition>
<custom name="client_ssl_disabled" excluded_value="true"/>
</condition>
</cluster>
</cluster>
<cluster name="spec_before_15_01" location="$|spec\before_15_01\" recursive="true">
<condition>
<version type="compiler" max="15.2.0.0"/>
<custom name="ssl_enabled" excluded_value="true"/>
<custom name="net_ssl_enabled" excluded_value="true"/>
</condition>
</cluster>
</cluster>

View File

@@ -23,8 +23,8 @@ feature {NONE} -- Initialization
opts.set_verbose_level ("debug")
opts.set_ssl_enabled (True) -- If SSL is supported
opts.set_ssl_ca_crt ("C:\OpenSSL-Win64\bin\ca.crt") -- Change to use your own crt file.
opts.set_ssl_ca_key ("C:\OpenSSL-Win64\bin\ca.key") -- Change to use your own key file.
opts.set_ssl_ca_crt ("ca.crt") -- Change to use your own crt file.
opts.set_ssl_ca_key ("ca.key") -- Change to use your own key file.
opts.set_port (default_port_number)
end

View File

@@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICWDCCAcGgAwIBAgIJAJnXGtV+PtiYMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQ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B+BaLRIWvRWb7Gdw203tu4e136Ca5uuY+71qdbVTVcl
NQ7J+T+eAQFP+a+DdT3ZQxu9eze87SMbu6i5YSpIk2kusOECQQDunv/DQ+nc+NgR
DF+Td3sNYUVRT9a1CWi6abAG6reXwp8MS4NobWDf+Ps4JODhEEwlIdq5qL7qqYBZ
Gc1TJJ53AkEA0404Fn6vAzzegBcS4RLlYTK7nMr0m4pMmDMCI6YzAYdMmKHp1e6f
IwxSmQrmwyAgwcT01bc0+A8yipcC2BWQaQJBAJ01QZm635OGmos41KsKF5bsE8gL
SpBBH69Yu/ECqGwie7iU84FUNnO4zIHjwghlPVVlZX3Vz9o4S+fn2N9DC+cCQGyZ
QyCxGdC0r5fbwHJQS/ZQn+UGfvlVzqoXDVMVn3t6ZES6YZrT61eHnOM5qGqklIxE
Old3vDZXPt/MU8Zvk3kCQBOgUx2VxvTrHN37hk9/QIDiM62+RenBm1M3ah8xTosf
1mSeEb6d9Kwb3TgPBmA7YXzJuAQfRIvEPMPxT5SSr6Q=
-----END RSA PRIVATE KEY-----

View File

@@ -32,18 +32,16 @@
<root class="APPLICATION" feature="make_and_launch"/>
<option concurrency="thread" root_concurrency="thread">
</option>
<variable name="httpd_ssl_enabled" value="true"/>
</target>
<target name="echo_websocket_server_mt_no_ssl" extends="echo_websocket_server_mt">
<variable name="httpd_ssl_enabled" value="false"/>
<target name="echo_websocket_server_mt_ssl" extends="echo_websocket_server_mt">
<variable name="ssl_enabled" value="true"/>
</target>
<target name="echo_websocket_server_scoop" extends="common">
<root class="APPLICATION" feature="make_and_launch"/>
<option concurrency="scoop" root_concurrency="scoop">
</option>
</target>
<target name="echo_websocket_server_scoop_ssl" extends="echo_websocket_server_scoop">
<variable name="httpd_ssl_enabled" value="true"/>
</target>
<target name="echo_websocket_server_scoop_no_ssl" extends="echo_websocket_server_scoop">
<variable name="httpd_ssl_enabled" value="false"/>
</target>
</system>