0
我使用框架Socket.IO-cleint-swift。下面是創建和連接代碼:如何使用自簽名證書上的Socket-IO-Swift進行連接?
let socket = SocketIOClient.init(socketURL: URL(string: "https://ts4.steelsea.net:8080")!, config: [.log(true), .forcePolling(true),.secure(true),.selfSigned(true)])
socket.on("connect") {data, ack in
print("socket connected")
}
socket.on("currentAmount") {data, ack in
if let cur = data[0] as? Double {
socket.emitWithAck("canUpdate", cur).timingOut(after: 0) {data in
socket.emit("update", ["amount": cur + 2.50])
}
ack.with("Got your currentAmount", "dude")
}
}
socket.connect()
下面是一個錯誤:
ERROR SocketIOClient: The certificate for this server is invalid. You might be connecting to a server that is pretending to be 「ts4.steelsea.net」 which could put your confidential information at risk.
我無法弄清楚如何確認該證書給我。
去https://ts4.steelsea.net:8080,並通過簡單的瀏覽器連接,並檢查certificate.Certificate的驗證是無效的。預計錯誤 –