$Sock SSL On: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
Line 17: Line 17:
===$Sock_SSL_On return codes===  
===$Sock_SSL_On return codes===  
<var>$Sock_SSL_On</var> return codes are:  
<var>$Sock_SSL_On</var> return codes are:  
<dl>  
<table>  
<dt>0 <dd>Successfully switched to SSL.  
<tr><th>0 </th>
<dt>-110 <dd>Attempted on non-SSL port. <var>$Sock_SSL_On</var> can only be attempted on a port with <var>SSL</var> and <var>SSLOPT</var> on the <var>[[JANUS DEFINE]]</var> command.  
<td>Successfully switched to SSL. </td></tr>
<dt>-111 <dd>SSL handshake error. Likely result of trying to use <var>$Sock_SSL_On</var> against a non-SSL port.  
<tr><th>-110</th>
<dt>-112 <dd>Have pending incoming data. <var>$Sock_SSL_On</var> is invalid until all incoming (presumably) non-SSL data has been received.  
<td>Attempted on non-SSL port. <var>$Sock_SSL_On</var> can only be attempted on a port with <var>SSL</var> and <var>SSLOPT</var> on the <var>[[JANUS DEFINE]]</var> command. </td></tr>
<dt>-149 <dd>Other error during connection.  
<tr><th>-111</th>
</dl>  
<td>SSL handshake error. Likely result of trying to use <var>$Sock_SSL_On</var> against a non-SSL port. </td></tr>
<tr><th>-112</th>
<td>Have pending incoming data. <var>$Sock_SSL_On</var> is invalid until all incoming (presumably) non-SSL data has been received. </td></tr>
<tr><th>-149</th>
<td>Other error during connection. </td></tr>


==Usage notes==  
==Usage notes==  

Revision as of 03:47, 20 January 2012

Switch to SSL processing

Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no direct OO equivalent for this $function.

$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:

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.

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.