【发布时间】:2014-04-25 13:37:34
【问题描述】:
我正在开发一个 Chrome 打包应用程序,它是一个通过 TCP 向外部 tcp 服务器发送数据的客户端应用程序。
如何确保我连接的套接字使用 TLS?在客户端连接中的什么时候,我需要添加一个参数来启用它?证书如何/在哪里存储?我需要手动处理还是 Chrome 会帮我处理?
这是我的代码示例:
chrome.app.runtime.onLaunched.addListener(function(launchData){
chrome.sockets.tcp.create({persistent: false, name: 'my_socket'}, function(createInfo) {
var socketId = createInfo.socketId;
chrome.storage.local.set({socketId: socketId}, function(){
chrome.sockets.tcp.connect(socketId, IP_ADDRESS, PORT, function(result){
if (result < 0){
// There was an error.
} else {
chrome.sockets.tcp.setKeepAlive(socketId, true, 60, function(result){
if (result < 0){
// There was an error.
} else {
chrome.sockets.tcp.send(socketId, myData, function(sendInfo){
if (!sendInfo || sendInfo.resultCode < 0){
// There was an error.
} else {
// Data Sent, await response in chrome.sockets.tcp.onReceive
}
});
}
});
}
});
});
});
});
【问题讨论】:
-
据我所知,TLS 是应用层,所以你的问题不正确。要使用 TLS,您需要在您的应用中实现它。
标签: javascript sockets google-chrome tcp google-chrome-app