diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2018-11-07 17:35:46 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2018-11-07 17:36:18 +0000 |
commit | 738abc1de7e5905d3b323f1ddb3938754024c844 (patch) | |
tree | 9f2d8ba0eb6e50a1b36b06336f0b75ff16c454fb /net | |
parent | 5ba1dec1f82fcb66e3b154fa0a507497a52a6714 (diff) |
Respond to SSL/TLS over http - when we don't expect it.
Change-Id: I48c7607cd4e1416fb4ac28c552c2cd96b51d60a6
Diffstat (limited to 'net')
-rw-r--r-- | net/Socket.cpp | 12 | ||||
-rw-r--r-- | net/Socket.hpp | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/net/Socket.cpp b/net/Socket.cpp index 208efc3c9..44f5d18a4 100644 --- a/net/Socket.cpp +++ b/net/Socket.cpp @@ -607,6 +607,18 @@ namespace HttpHelper } } +bool StreamSocket::sniffSSL() const +{ + // Only sniffing the first bytes of a sockte. + if (_bytesSent > 0 || _bytesRecvd != _inBuffer.size() || _bytesRecvd < 6) + return false; + + // 0x0000 16 03 01 02 00 01 00 01 + return (_inBuffer[0] == 0x16 && // HANDSHAKE + _inBuffer[1] == 0x03 && // SSL 3.0 / TLS 1.x + _inBuffer[5] == 0x01); // Handshake: CLIENT_HELLO +} + #endif // !MOBILEAPP /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/net/Socket.hpp b/net/Socket.hpp index e62b01039..db4f58760 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -1073,6 +1073,9 @@ public: while (!_outBuffer.empty()); } + /// Does it look like we have some TLS / SSL where we don't expect it ? + bool sniffSSL() const; + protected: /// Override to handle reading of socket data differently. virtual int readData(char* buf, int len) |