1 USING: io help.markup help.syntax calendar quotations io.sockets ;
4 HELP: secure-socket-timeout
5 { $var-description "Timeout for operations not associated with a constructed port instance, such as SSL handshake and shutdown. Represented as a " { $link duration } "." } ;
8 { $description "Possible value for the " { $snippet "method" } " slot of a " { $link secure-config } "."
10 "Note that the SSLv2 protocol is vulnerable to truncation attacks and its use is discouraged (" { $url "http://www.gnu.org/software/gnutls/manual/html_node/On-SSL-2-and-older-protocols.html" } ")." } ;
13 { $description "Possible value for the " { $snippet "method" } " slot of a " { $link secure-config } "."
15 "SSLv3 is widely used, however it is being supersceded by TLSv1." } ;
18 { $description "Possible value for the " { $snippet "method" } " slot of a " { $link secure-config } "."
20 "This value indicates that either SSLv2 or SSLv3 is acceptable." } ;
23 { $description "Possible value for the " { $snippet "method" } " slot of a " { $link secure-config } "."
25 "TLSv1 is the newest protocol for secure socket communications." } ;
27 ARTICLE: "ssl-methods" "SSL/TLS methods"
28 "The " { $snippet "method" } " slot of a " { $link secure-config } " can be set to one of the following values:"
30 { $subsection SSLv23 }
33 "The default value is " { $link SSLv23 } "." ;
36 { $class-description "Instances represent secure socket configurations." } ;
39 { $values { "config" secure-config } }
40 { $description "Creates a new secure socket configration with default values." } ;
42 ARTICLE: "ssl-key-file" "The key file and password"
43 "The " { $snippet "key-file" } " and " { $snippet "password" } " slots of a " { $link secure-config } " can be set to a private key file in PEM format. These slots are required for secure servers, and also for clients when client-side authentication is used." ;
45 ARTICLE: "ssl-ca-file" "The CA file and path"
46 "The " { $snippet "ca-file" } " slot of a " { $link secure-config } " can contain the path of a file with a list of trusted certificates in PEM format. The " { $snippet "ca-path" } " slot can contain the path of a directory of trusted certifications."
48 "One of these slots are required to be specified so that secure client sockets can verify server certificates."
50 "See " { $url "http://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html" } " for details." ;
52 ARTICLE: "ssl-dh-file" "Diffie-Hellman parameter file"
53 "The " { $snippet "dh-file" } " slot of a " { $link secure-config } " can contain the path of a file with Diffie-Hellman key exchange parameters."
55 "This slot is required for secure server sockets." ;
57 ARTICLE: "ssl-ephemeral-rsa" "Ephemeral RSA key bits"
58 "The " { $snippet "ephemeral-key-bits" } " slot of a " { $link secure-config } " contains the length of the empheral RSA key, in bits."
60 "The default value is 1024, and anything less than that is considered insecure. This slot is required for secure server sockets." ;
62 ARTICLE: "ssl-config" "Secure socket configuration"
63 "Secure sockets require some configuration, particularly for server sockets. A class represents secure socket configuration parameters:"
64 { $subsection secure-config }
65 "Creating new instances:"
66 { $subsection <secure-config> }
67 "Configuration parameters:"
68 { $subsection "ssl-methods" }
69 { $subsection "ssl-key-file" }
70 { $subsection "ssl-ca-file" }
71 { $subsection "ssl-dh-file" }
72 { $subsection "ssl-ephemeral-rsa" } ;
74 HELP: <secure-context>
75 { $values { "config" secure-config } { "context" secure-context } }
76 { $description "Creates a new " { $link secure-context } ". This word should not usually be called directly, use " { $link with-secure-context } " instead." } ;
78 HELP: with-secure-context
79 { $values { "config" secure-config } { "quot" quotation } }
80 { $description "Calls the quotation in a new dynamic scope where a " { $link secure-context } " constructed from the specified configuration is available." } ;
82 ARTICLE: "ssl-contexts" "Secure socket contexts"
83 "All secure socket operations must be performed in a secure socket context. A context is created from a secure socket configuration. An implicit context with the default configuration is always available, however server sockets require a certificate to be set together with other parameters, and the default configuration is insufficient, so a context must be explicitly created in that case."
84 { $subsection with-secure-context } ;
87 { $class-description "The class of secure socket addresses." } ;
90 { $values { "addrspec" "an address specifier" } { "secure" secure } }
91 { $description "Creates a new secure socket address, which can then be passed to " { $link <client> } " or " { $link <server> } "." } ;
93 ARTICLE: "ssl-addresses" "Secure socket addresses"
94 "Secure socket connections are established by passing a secure socket address to " { $link <client> } " or " { $link <server> } "."
96 "Secure socket addresses form a class:"
97 { $subsection secure }
98 "Constructing secure socket addresses:"
99 { $subsection <secure> }
100 "Instances of this class can wrap an " { $link inet } ", " { $link inet4 } " or an " { $link inet6 } ", although note that certificate validation is only performed for instances of " { $link inet } " since otherwise the host name is not available." ;
102 HELP: send-secure-handshake
103 { $contract "Upgrades the socket connection of the current " { $link with-client } " scope to a secure connection and initiates a SSL/TLS handshake." }
104 { $errors "Throws " { $link upgrade-on-non-socket } " or " { $link upgrade-buffers-full } " if used improperly." }
105 { $examples "This word is used by the " { $vocab-link "smtp" } " library to implement SMTP-TLS." } ;
107 HELP: accept-secure-handshake
108 { $contract "Upgrades the socket connection stored in the " { $link input-stream } " and " { $link output-stream } " variables to a secure connection and waits for an SSL/TLS handshake." }
109 { $errors "Throws " { $link upgrade-on-non-socket } " or " { $link upgrade-buffers-full } " if used improperly." } ;
111 ARTICLE: "ssl-upgrade" "Upgrading existing connections"
112 "Some protocols, such as HTTPS, require that the connection be established as an SSL/TLS connection. Others, such as secure SMTP and POP3 require that the client and server initiate an SSL/TLS handshake upon the client sending a plain-text request. The latter use-case is accomodated by a pair of words."
114 "Upgrading a connection to a secure socket by initiating an SSL/TLS handshake with the server:"
115 { $subsection send-secure-handshake }
116 "Upgrading a connection to a secure socket by waiting for an SSL/TLS handshake from the client:"
117 { $subsection accept-secure-handshake } ;
119 HELP: premature-close
120 { $error-description "Thrown if an SSL connection is closed without the proper " { $snippet "close_notify" } " sequence. This error is never reported for " { $link SSLv2 } " connections because there is no distinction between expected and unexpected connection closure in that case." } ;
122 HELP: certificate-verify-error
123 { $error-description "Thrown if certificate verification failed. The " { $snippet "result" } " slot contains an object identifying the low-level error that occurred." } ;
125 HELP: common-name-verify-error
126 { $error-description "Thrown during certificate verification if the host name on the certificate does not match the host name the socket was connected to. This indicates a potential man-in-the-middle attack. The " { $slot "expected" } " and " { $slot "got" } " slots contain the mismatched host names." } ;
128 HELP: upgrade-on-non-socket
129 { $error-description "Thrown if " { $link send-secure-handshake } " or " { $link accept-secure-handshake } " is called with the " { $link input-stream } " and " { $link output-stream } " variables not set to a socket. This error can also indicate that the connection has already been upgraded to a secure connection." } ;
131 HELP: upgrade-buffers-full
132 { $error-description "Thrown if " { $link send-secure-handshake } " or " { $link accept-secure-handshake } " is called when there is still data which hasn't been read or written." }
133 { $notes "Clients should ensure to " { $link flush } " their last command to the server before calling " { $link send-secure-handshake } "." } ;
135 ARTICLE: "ssl-errors" "Secure socket errors"
136 "Secure sockets can throw one of several errors in addition to the usual I/O errors:"
137 { $subsection premature-close }
138 { $subsection certificate-verify-error }
139 { $subsection common-name-verify-error }
140 "The " { $link send-secure-handshake } " word can throw one of two errors:"
141 { $subsection upgrade-on-non-socket }
142 { $subsection upgrade-buffers-full } ;
144 ARTICLE: "io.sockets.secure" "Secure sockets (SSL, TLS)"
145 "The " { $vocab-link "io.sockets.secure" } " vocabulary implements secure, encrypted sockets using the OpenSSL library."
147 "At present, this vocabulary only works on Unix, and not on Windows."
149 "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (" { $url "http://www.openssl.org/" } "), cryptographic software written by Eric Young (eay@cryptsoft.com) and software written by Tim Hudson (tjh@cryptsoft.com)."
150 { $subsection "ssl-config" }
151 { $subsection "ssl-contexts" }
152 { $subsection "ssl-addresses" }
153 { $subsection "ssl-upgrade" }
154 { $subsection "ssl-errors" } ;
156 ABOUT: "io.sockets.secure"