[TIMOB-27327] Add support for SSL/TLS in Ti.Network.Socket.TCP
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | None |
Status | In Progress |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android, iOS |
Labels | n/a |
Reporter | Jan Vennemann |
Assignee | Jan Vennemann |
Created | 2019-08-09T21:55:23.000+0000 |
Updated | 2019-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.
No comments