Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27327

Add support for SSL/TLS in Ti.Network.Socket.TCP

    Details

    • Type: Improvement
    • Status: In Progress
    • Priority: None
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android, iOS
    • Labels:
      None

      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.

        Attachments

          Activity

            People

            • Assignee:
              jvennemann Jan Vennemann
              Reporter:
              jvennemann Jan Vennemann
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code