{ "id": "82825", "key": "TIMOB-6212", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2011-11-17T07:23:38.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "exalture" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "issuelinks": [ { "id": "13914", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "outwardIssue": { "id": "82561", "key": "MOD-286", "fields": { "summary": "Implement TLS based secure socket for iOS and Android", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } }, { "id": "41645", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "82826", "key": "TIDOC-288", "fields": { "summary": "APIDoc: Document Support for TLS to TCP Sockets", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-08-02T17:31:47.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h1. Problem\r\nFacebook chat now requires a secure connection, so any apps that are using it are now broken until TLS is exposed through our TCP sockets.\r\n\r\nh2. Pull Request\r\nhttps://github.com/appcelerator/titanium_mobile/pull/726\r\n\r\nh2. How to Test\r\nDrop the following in an app.js. Look at the log. After some network traffic (~5 seconds) you should see the log message, \"Socket secured!\". (Note that around 10 seconds later, the connection will timeout and you'll be disconnected -- this is expected behavior.)\r\n\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n\r\nvar states = {\r\n WAITING_FOR_FIRST_RESPONSE: 0,\r\n WAITING_FOR_START_TLS: 1,\r\n WAITING_FOR_PROCEED: 2,\r\n WAITING_FOR_SECURED: 3,\r\n DONE: 4,\r\n ERRORED: 5\r\n};\r\nvar currentState = Ti.Android ? states.WAITING_FOR_FIRST_RESPONSE : states.WAITING_FOR_START_TLS;\r\n\r\nvar socket = Ti.Network.Socket.createTCP({\r\n host: 'chat.facebook.com', port: 5222,\r\n connected: function (e) {\r\n Ti.API.info('Socket opened!');\r\n Ti.Stream.pump(e.socket, read, 1024, true);\r\n socket.write(Ti.createBuffer({\r\n value: ''\r\n }));\r\n },\r\n secured: function (e) {\r\n Ti.API.info('Socket secured!');\r\n },\r\n error: function (e) {\r\n Ti.API.info('Error (' + e.errorCode + '): ' + e.error);\r\n },\r\n closed: function (e) {\r\n Ti.API.info('Socket closed!');\r\n }\r\n});\r\nsocket.connect();\r\n\r\nfunction write(msg) {\r\n Ti.API.info('State: ' + currentState + ', Wrote: ' + msg);\r\n socket.write(Ti.createBuffer({\r\n value: msg\r\n }));\r\n}\r\n\r\nfunction read(e) {\r\n try {\r\n if (e.buffer) {\r\n var received = e.buffer.toString();\r\n Ti.API.info('State: ' + currentState + ', Received: ' + received);\r\n switch (currentState) {\r\n\r\n case states.WAITING_FOR_FIRST_RESPONSE:\r\n if (received.split('');\r\n if (!Ti.Android) {\r\n // Note: iOS requires that startTLS be called right after sending the above XML.\r\n // This is required because of how reads and writes are queued up before a secure handshake.\r\n socket.startTLS();\r\n return currentState = states.WAITING_FOR_SECURED;\r\n }\r\n return currentState = states.WAITING_FOR_PROCEED;\r\n\r\n case states.WAITING_FOR_PROCEED:\r\n if (received.split('').length <= 1) {\r\n Ti.API.error('Unexpected response from server while WAITING_FOR_PROCEED!');\r\n return currentState = states.ERRORED;\r\n }\r\n socket.startTLS();\r\n return currentState = states.WAITING_FOR_SECURED;\r\n\r\n case states.WAITING_FOR_SECURED:\r\n write('');\r\n return currentState = states.DONE;\r\n\r\n }\r\n }\r\n else {\r\n Ti.API.error('Error: no e.buffer!');\r\n }\r\n } catch (ex) {\r\n Ti.API.error(ex);\r\n }\r\n}\r\n\r\nwin.open();\r\n{code}\r\n\r\nh2. Related Tickets\r\niOS: [TIMOB-6211]\r\nAndroid: [TIMOB-6212]\r\nAPIDoc: [TIMOB-6213]", "attachment": [], "flagged": false, "summary": "Android: Add Support for TLS to TCP Sockets", "creator": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "173086", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Opened pull request https://github.com/appcelerator/titanium_mobile/pull/726", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-11-17T07:36:16.000+0000", "updated": "2011-11-17T07:36:16.000+0000" }, { "id": "173089", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Revamped the description so that it is clear what this is addressing and how it can be tested.", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-11-17T07:42:06.000+0000", "updated": "2011-11-17T07:42:06.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }