SSLOn (Socket function): Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 2: | Line 2: | ||
This [[Notation conventions for methods#Callable functions|callable]] method turns on SSL processing, that is, starts an SSL handshake as a client | This [[Notation conventions for methods#Callable functions|callable]] method turns on SSL processing, that is, starts an SSL handshake as a client | ||
on a connection. | on a connection. | ||
<var>SSLOn</var> has an effect similar to <var>[[$ | <var>SSLOn</var> has an effect similar to <var>[[$Sock_SSL_On]]</var>. | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 10: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%number</th> | <tr><th>%number</th> | ||
<td> | <td>A numeric variable to contain the returned indicator of success of the function. | ||
The possible return values are listed in [[#Return codes| | The possible return values are listed in [[#Return codes|Return codes]] below. </td></tr> | ||
<tr><th>socket</th> | <tr><th>socket</th> | ||
Line 19: | Line 19: | ||
===Return codes=== | ===Return codes=== | ||
The method's return value (<var class="term">%number</var>) is one of these: | The method's return value (<var class="term">%number</var>) is one of these: | ||
<table> | <table class="thJustBold"> | ||
<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> | ||
<td>Attempted on non-SSL port. <var>SSLOn</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> | <td>Attempted on non-SSL port. <var>SSLOn</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> | ||
<tr><th>-111</th> | <tr><th>-111</th> | ||
<td>SSL handshake error. Likely result of trying to use the <var>SSLOn</var> method against a non-SSL port.</td></tr> | <td>SSL handshake error. Likely result of trying to use the <var>SSLOn</var> method against a non-SSL port.</td></tr> | ||
<tr><th>-112</th> | <tr><th>-112</th> | ||
<td>Have pending incoming data. The <var>SSLOn</var> method is invalid until all incoming (presumably) non-SSL data has been received.</td></tr> | <td>Have pending incoming data. The <var>SSLOn</var> method is invalid until all incoming (presumably) non-SSL data has been received.</td></tr> | ||
<tr><th>-149</th> | <tr><th>-149</th> | ||
<td>Other error during connection.</td></tr> | <td>Other error during connection.</td></tr> | ||
Line 33: | Line 37: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li><var>SSLOn</var> makes it possible to: | <li><var>SSLOn</var> makes it possible to: | ||
<ol> | <ol> | ||
<li>Make an initial connection from a <var class="product">Janus Sockets</var> client application to a proxy server | <li>Make an initial connection from a <var class="product">Janus Sockets</var> client application to a proxy server | ||
<li>Issue the HTTP CONNECT | |||
method/command to connect to a server through the proxy | <li>Issue the HTTP CONNECT method/command to connect to a server through the proxy | ||
<li>Communicate via SSL with the back end server, simply having the proxy server | |||
act as a "tunnel" for the SSL data | <li>Communicate via SSL with the back end server, simply having the proxy server | ||
</ol> | act as a "tunnel" for the SSL data | ||
</ol> </li> | |||
As shown in [[#Examples| | |||
<li>As shown in [[#Examples|Examples]] below, the <var>SSLOn</var> method should be | |||
used after a positive response has been received for a CONNECT method | used after a positive response has been received for a CONNECT method | ||
request on a <var class="product">Janus Sockets</var> client socket. | request on a <var class="product">Janus Sockets</var> client socket. </li> | ||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
The following code shows the use of the <var>SSLOn</var> method; | The following code shows the use of the <var>SSLOn</var> method; | ||
<p class="code">%sock is Object <var>Socket</var> | <p class="code">%sock is Object <var>Socket</var> |
Latest revision as of 18:08, 12 August 2014
Turn on SSL processing (Socket class)
This callable method turns on SSL processing, that is, starts an SSL handshake as a client on a connection. SSLOn has an effect similar to $Sock_SSL_On.
Syntax
[%number =] socket:SSLOn
Syntax terms
%number | A numeric variable to contain the returned indicator of success of the function. The possible return values are listed in Return codes below. |
---|---|
socket | A variable or an expression that is a reference to a Socket object. |
Return codes
The method's return value (%number) is one of these:
0 | Successfully switched to SSL. |
---|---|
-110 | Attempted on non-SSL port. SSLOn 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 the SSLOn method against a non-SSL port. |
-112 | Have pending incoming data. The SSLOn method is invalid until all incoming (presumably) non-SSL data has been received. |
-149 | Other error during connection. |
Usage notes
- SSLOn makes it possible to:
- Make an initial connection from a Janus Sockets client application to a proxy server
- Issue the HTTP CONNECT method/command to connect to a server through the proxy
- Communicate via SSL with the back end server, simply having the proxy server act as a "tunnel" for the SSL data
- As shown in Examples below, the SSLOn method should be used after a positive response has been received for a CONNECT method request on a Janus Sockets client socket.
Examples
The following code shows the use of the SSLOn method;
%sock is Object Socket %sock = New('WEBDROPS', 'proxy') %r = %sock:Set('LINEND', '0D0A') %r = %sock:Set('PRSTOK', '0D0A') %r = %sock:Send('CONNECT ') %r = %sock:Send('sirius-software.com:443') %r = %sock:SendWithLineEnd(' HTTP/1.0') %r = %sock:SendWithLineEnd() %r = %sock:ReceiveAndParse(%s) If $WORD(%s, , 2) Ne '200' Then Call CONNECT_ERROR End If Repeat Forever %r = %sock:ReceiveAndParse(%s) If $LSTR_LEN(%s) Eq 0 Then Loop End End If End Repeat %r = %sock:SSLOn If %r Then Call SSL_ERROR End If %r = %sock:Send('GET ') %r = %sock:Send(%URL) %r = %sock:SendWithLineEnd(' HTTP/1.0') %r = %sock:SendWithLineEnd() ...
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.