Skip to content

Commit ef3ceb1

Browse files
SijaSantiago Palladino
authored and
Santiago Palladino
committedJan 19, 2017
Tweak OpenSSL docs
1 parent a38087e commit ef3ceb1

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed
 

‎src/openssl.cr

+25-16
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,48 @@ require "./openssl/lib_ssl"
33
# # OpenSSL Integration
44
#
55
# - TLS sockets need a context, potentially with keys (required for servers) and configuration.
6-
# - TLS sockets will wrap the underlying TCP socket, and any further communication must happen through the OpenSSL::SSL::Socket only.
6+
# - TLS sockets will wrap the underlying TCP socket, and any further communication must happen through the `OpenSSL::SSL::Socket` only.
77
#
88
# ## Usage Example
9-
# - Note: for the below "server" example to work, a key pair should be attained
109
#
11-
# Recommended ciphers can be taken from
12-
# - https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Cryptographic_Ciphers
13-
# - https://cipherli.st/
14-
# - Full list is available at: https://wiki.openssl.org/index.php/Manual:Ciphers(1)#CIPHER_STRINGS
10+
# Recommended ciphers can be taken from:
11+
# - [OWASP Wiki](https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Cryptographic_Ciphers)
12+
# - [Cipherli.st](https://cipherli.st/)
13+
# - Full list is available at [OpenSSL Wiki](https://wiki.openssl.org/index.php/Manual:Ciphers%281%29#CIPHER_STRINGS)
1514
#
16-
# Do note that
17-
# - Crystal does its best to provide sane configuration defaults (see [Mozilla-Intermediate](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28default.29))
18-
# - Linked version of OpenSSL need to be checked for supporting specific protocols and ciphers
15+
# Do note that:
16+
# - Crystal does its best to provide sane configuration defaults (see [Mozilla-Intermediate](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28default.29)).
17+
# - Linked version of OpenSSL need to be checked for supporting specific protocols and ciphers.
1918
# - If any configurations or choices in Crystal regarding SSL settings and security are found to be lacking or need
20-
# improvement please open an issue and let us know
19+
# improvement please [open an issue](https://github.com/crystal-lang/crystal/issues/new) and let us know.
2120
#
2221
# ### Server side
2322
#
23+
# NOTE: For the below example to work, a key pair should be attained.
24+
#
2425
# ```
2526
# require "socket"
2627
# require "openssl"
2728
#
2829
# def server
29-
# socket = TCPServer.new(5555) # Bind new TCPSocket to port 5555
30+
# # Bind new TCPSocket to port 5555
31+
# socket = TCPServer.new(5555)
32+
#
3033
# context = OpenSSL::SSL::Context::Server.new
3134
# context.private_key = "/path/to/private.key"
3235
# context.certificate_chain = "/path/to/public.cert"
33-
# puts "server is up"
36+
#
37+
# puts "Server is up"
38+
#
3439
# socket.accept do |client|
35-
# puts "got client"
40+
# puts "Got client"
41+
#
42+
# bytes = Bytes.new(20)
43+
#
3644
# ssl_socket = OpenSSL::SSL::Socket::Server.new(client, context)
37-
# slice = Slice(UInt8).new(20)
38-
# ssl_socket.read(slice)
39-
# puts String.new(slice)
45+
# ssl_socket.read(bytes)
46+
#
47+
# puts String.new(bytes)
4048
# end
4149
# end
4250
# ```
@@ -50,6 +58,7 @@ require "./openssl/lib_ssl"
5058
# def client
5159
# socket = TCPSocket.new("127.0.0.1", 5555)
5260
# context = OpenSSL::SSL::Context::Client.new
61+
#
5362
# ssl_socket = OpenSSL::SSL::Socket::Client.new(socket, context)
5463
# ssl_socket.write("Testing".to_slice)
5564
# end

0 commit comments

Comments
 (0)
Please sign in to comment.