|
|
@ -500,6 +500,8 @@ namespace data |
|
|
|
if (u.port_ == 80) u.port_ = 443; |
|
|
|
if (u.port_ == 80) u.port_ = 443; |
|
|
|
TlsSession session (u.host_, u.port_); |
|
|
|
TlsSession session (u.host_, u.port_); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (session.IsEstablished ()) |
|
|
|
|
|
|
|
{ |
|
|
|
// send request
|
|
|
|
// send request
|
|
|
|
std::stringstream ss; |
|
|
|
std::stringstream ss; |
|
|
|
ss << "GET " << u.path_ << " HTTP/1.1\r\nHost: " << u.host_ |
|
|
|
ss << "GET " << u.path_ << " HTTP/1.1\r\nHost: " << u.host_ |
|
|
@ -512,6 +514,9 @@ namespace data |
|
|
|
; |
|
|
|
; |
|
|
|
return i2p::util::http::GetHttpContent (rs); |
|
|
|
return i2p::util::http::GetHttpContent (rs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
@ -622,13 +627,11 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TlsSession::TlsSession (const std::string& host, int port): |
|
|
|
TlsSession::TlsSession (const std::string& host, int port): |
|
|
|
m_Cipher (nullptr) |
|
|
|
m_IsEstablished (false), m_Cipher (nullptr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_Site.connect(host, boost::lexical_cast<std::string>(port)); |
|
|
|
m_Site.connect(host, boost::lexical_cast<std::string>(port)); |
|
|
|
if (m_Site.good ()) |
|
|
|
if (m_Site.good ()) |
|
|
|
{ |
|
|
|
|
|
|
|
Handshake (); |
|
|
|
Handshake (); |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogError, "Can't connect to ", host, ":", port); |
|
|
|
LogPrint (eLogError, "Can't connect to ", host, ":", port); |
|
|
|
} |
|
|
|
} |
|
|
@ -693,7 +696,9 @@ namespace data |
|
|
|
LogPrint (eLogError, "Unexpected handshake type ", (int)serverHello[0]); |
|
|
|
LogPrint (eLogError, "Unexpected handshake type ", (int)serverHello[0]); |
|
|
|
uint8_t sessionIDLen = serverHello[38]; // 6 + 32
|
|
|
|
uint8_t sessionIDLen = serverHello[38]; // 6 + 32
|
|
|
|
char * cipherSuite = serverHello + 39 + sessionIDLen; |
|
|
|
char * cipherSuite = serverHello + 39 + sessionIDLen; |
|
|
|
if (cipherSuite[1] != 0x3D && cipherSuite[1] != 0x35 && cipherSuite[1] != 0x05) |
|
|
|
if (cipherSuite[1] == 0x3D || cipherSuite[1] == 0x35 || cipherSuite[1] == 0x05) |
|
|
|
|
|
|
|
m_IsEstablished = true; |
|
|
|
|
|
|
|
else |
|
|
|
LogPrint (eLogError, "Unsupported cipher ", (int)cipherSuite[0], ",", (int)cipherSuite[1]); |
|
|
|
LogPrint (eLogError, "Unsupported cipher ", (int)cipherSuite[0], ",", (int)cipherSuite[1]); |
|
|
|
// read Certificate
|
|
|
|
// read Certificate
|
|
|
|
m_Site.read ((char *)&type, 1); |
|
|
|
m_Site.read ((char *)&type, 1); |
|
|
|