$Sock SSL On: Difference between revisions
mNo edit summary |
(Automatically generated page update) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:$Sock_SSL_On}} | {{DISPLAYTITLE:$Sock_SSL_On}} | ||
<span class="pageSubtitle">Switch to SSL processing</span> | <span class="pageSubtitle">Switch to SSL processing</span> | ||
<p class=" | <p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented | ||
methods. | methods. The OO equivalent for <var>$Sock_SSL_On</var> is the <var>[[SSLOn (Socket function)|SSLOn]]</var> method.</p> | ||
<var>$Sock_SSL</var> turns on SSL processing, that is, starts an SSL handshake as a client on a connection. | <var>$Sock_SSL</var> turns on SSL processing, that is, starts an SSL handshake as a client on a connection. | ||
Line 18: | Line 18: | ||
<var>$Sock_SSL_On</var> return codes are: | <var>$Sock_SSL_On</var> return codes are: | ||
<table> | <table> | ||
<tr><th>0</th> | <tr><th> 0</th> | ||
<td>Successfully switched to SSL. </td></tr> | <td>Successfully switched to SSL. </td></tr> | ||
<tr><th>-110</th> | <tr><th>-110</th> |
Latest revision as of 00:00, 21 September 2018
Switch to SSL processing
Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Sock_SSL_On is the SSLOn method.
$Sock_SSL turns on SSL processing, that is, starts an SSL handshake as a client on a connection.
Syntax
[%rc =] = $Sock_SSL_On(sockNum)
Syntax terms
%rc | A numeric return code: 0 if successful, otherwise a negative value, as described below. |
---|---|
sockNum | The socket number, or it is -1, which indicates that the change affects all relevant sockets. |
$Sock_SSL_On return codes
$Sock_SSL_On return codes are:
0 | Successfully switched to SSL. |
---|---|
-110 | Attempted on non-SSL port. $Sock_SSL_On can only be attempted on a port with SSL and SSLOPT on the JANUS DEFINE command. |
-111 | SSL handshake error. Likely result of trying to use $Sock_SSL_On against a non-SSL port. |
-112 | Have pending incoming data. $Sock_SSL_On is invalid until all incoming (presumably) non-SSL data has been received. |
-149 | Other error during connection. |
Usage notes
This function makes it possible to make an initial connection from a Janus Sockets client application to a proxy server, use the CONNECT method to connect to a server through the proxy, and then communicate via SSL with the back end server, simply having the proxy server act as a "tunnel" for the SSL data. Basically, $Sock_SSL_On should be used after a positive response has been received for a CONNECT method request on a Janus Sockets client socket.
Example
The following code illustrates the use of $Sock_SSL_On:
%x = $Sock_Conn('WEBDROPS', 'proxy') %r = $Sock_Set(%x, 'LINEND', '0D0A') %r = $Sock_Set(%x, 'PRSTOK', '0D0A') %r = $Sock_Send(%x, 'CONNECT ') %r = $Sock_Send(%x, 'sirius-software.com:443') %r = $Sock_SendLn(%x, ' HTTP/1.0') %r = $Sock_SendLn(%x, ) %r = $Sock_RecvPrs(%x, %s) If $WORD(%s, , 2) Ne '200' Then Call CONNECT_ERROR End If Repeat Forever %r = $Sock_RecvPrs(%x, %s) If $lstr_len(%s) Eq 0 Then Loop End End If End Repeat %r = $Sock_SSL_On(%x) If %r Then Call SSL_ERROR End If %r = $Sock_Send(%x, 'GET ') %r = $Sock_Send(%x, %URL) %r = $Sock_SendLn(%x, ' HTTP/1.0') %r = $Sock_SendLn(%x, ) ...
For more information about HTTP tunneling and the CONNECT method, see http://www.ietf.org/rfc/rfc2817.txt
. Many other references are also available on the web.