Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27327] Add support for SSL/TLS in Ti.Network.Socket.TCP

GitHub Issuen/a
TypeImprovement
PriorityNone
StatusIn Progress
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid, iOS
Labelsn/a
ReporterJan Vennemann
AssigneeJan Vennemann
Created2019-08-09T21:55:23.000+0000
Updated2019-09-26T12:22:59.000+0000

Description

Using a Ti.Network.Socket.TCP socket for connections protected with TLS currently doesn't work. No TLS handshake will be started although the underlying socket implementations support this. Support for TLS protected socket connections should be added. - Introduce new option useTls when creating a new TCP socket to manually enable TLS. *Steps to reproduce the behavior*
let httpHeader = GET /html HTTP/1.1\r\n;
httpHeader += Host: httpbin.org\r\n;
httpHeader += '\r\n';
const data = Ti.createBuffer({
  value: httpHeader
});
const socket = Ti.Network.Socket.createTCP({
  host: 'httpbin.org',
  port: 443,
  connected: e => {
    Ti.Stream.pump(socket, (e) => {
      if (e.bytesProcessed === -1 || e.bytesProcessed === "-1") {
        throw new Error('Socket EOF / Error')
      }

      const response = e.buffer.toString();
      console.log(response);
    }, 64 * 1024, true);
    socket.write(data, () => {});
  },
  error: e => {
    console.error(e.error);
  }
});
socket.connect();
*Actual behavior* The connection cannot be established and a socket error is thrown. *Epected behavior* The connection via TLS works without issues and the response is printed to the console.

Comments

No comments

JSON Source