Hello,
I am doing a Chrome Application using the new Socket API (Chrome.sockets.tcp). I have been able to successfully get all HTTP requests working without any issue. The problem that I have run into is the HTTPS login with TLS handshake. We created a Visual Studio C# (RestRequest) application. We are able to connect using HTTPS. Using Wireshark, I notice that the successful communication was achieved using the TLSv1.
I have tried a variety of solutions and referenced/experimented the below links and tried to come up with a solution.
https://groups.google.com/a/chromium.org/forum/#!msg/net-dev/U2ecAARKvAg/WI1WrSlaOPMJ
http://stackoverflow.com/questions/27911137/ssl-client-authentication-with-certificate-in-chrome-app
https://bugs.chromium.org/p/chromium/issues/detail?id=403076
https://github.com/MobileChromeApps/mobile-chrome-apps/issues/269
https://productforums.google.com/forum/#!topic/chrome/v15KaPnQfE0
https://github.com/flackr/circ/blob/master/package/bin/net/ssl_socket.js
Plus many more links! I have written a pile of test applications, but all reach a dead end after the initial handshake.
The following code sequence seems to get the handshake done, but I cannot send the login post. It seems as though the socket is messed up after the handshake. (WireShark shows all com’s were successful up until the login post).
var that = this;
chrome.sockets.tcp.create({persistent: false, name: "hc", bufferSize: 8192 }, function(createInfo){
console.log("create info = " + JSON.stringify(createInfo));
if (chrome.runtime.lastError) {
error('Unable to create socket: ' + chrome.runtime.lastError.message);
}
that._socketId = createInfo.socketId;
chrome.sockets.tcp.setPaused(that._socketId, true, function(){
chrome.sockets.tcp.connect(that._socketId, that._httpHost, that._httpPort, function(result){
chrome.sockets.tcp.onReceive.addListener(that._onReceive.bind(this));
chrome.sockets.tcp.onReceiveError.addListener(that._onReceiveError.bind(this));
chrome.sockets.tcp.secure(that._socketId, function(secureResult) {
chrome.sockets.tcp.send(that._socketId, str2ab('POST / HTTP/1.1\r\nHOST: ' + that._httpHost + '\r\n\r\n'), function(sendResult) {
});
});
});
});
});
I have tried implementing the TLSSocket from nmp forge and I get the same result as the example above.
We have to use TCP for this application, mainly for cookie support in a Chrome App.
Does anybody have a solution or suggestion? We have put in a lot of hours with trial and error, and seems like we have hit a dead end.
Thanks,
Tom