mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
process server certificate
This commit is contained in:
parent
c5f0be126e
commit
6ea037cc47
36
Reseed.cpp
36
Reseed.cpp
|
@ -401,6 +401,14 @@ namespace data
|
|||
decoder.Put ((const uint8_t *)base64.data(), base64.length());
|
||||
decoder.MessageEnd ();
|
||||
|
||||
LoadCertificate (queue);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Can't open certificate file ", filename);
|
||||
}
|
||||
|
||||
void Reseeder::LoadCertificate (CryptoPP::ByteQueue& queue)
|
||||
{
|
||||
// extract X.509
|
||||
CryptoPP::BERSequenceDecoder x509Cert (queue);
|
||||
CryptoPP::BERSequenceDecoder tbsCert (x509Cert);
|
||||
|
@ -465,9 +473,6 @@ namespace data
|
|||
tbsCert.SkipAll();
|
||||
x509Cert.SkipAll();
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Can't open certificate file ", filename);
|
||||
}
|
||||
|
||||
void Reseeder::LoadCertificates ()
|
||||
{
|
||||
|
@ -500,8 +505,8 @@ namespace data
|
|||
0x03, 0x02, // version (TSL 1.2)
|
||||
0x00, 0x2F, // length of handshake
|
||||
// handshake
|
||||
0x01, // client hello
|
||||
0x00, 0x00, 0x2B, // length of client hello
|
||||
0x01, // handshake type (client hello)
|
||||
0x00, 0x00, 0x2B, // length of handshake payload
|
||||
// client hello
|
||||
0x03, 0x02, // highest version supported (TSL 1.2)
|
||||
0x01, 0x01, 0x01, 0x01, // date, can be anything
|
||||
|
@ -533,6 +538,27 @@ namespace data
|
|||
char * serverHello = new char[length];
|
||||
site.read (serverHello, length);
|
||||
delete[] serverHello;
|
||||
// read Certificate
|
||||
site.read ((char *)&type, 1);
|
||||
site.read ((char *)&version, 2);
|
||||
site.read ((char *)&length, 2);
|
||||
length = be16toh (length);
|
||||
char * certificate = new char[length];
|
||||
site.read (certificate, length);
|
||||
// 0 - handshake type
|
||||
// 1 - 3 - handshake payload length
|
||||
// 4 - 6 - length of array of certificates
|
||||
// 7 - 9 - length of certificate
|
||||
if (certificate[0] == 0x0B) // handshake type certificate
|
||||
{
|
||||
CryptoPP::ByteQueue queue;
|
||||
queue.Put ((uint8_t *)certificate + 10, length - 10);
|
||||
queue.MessageEnd ();
|
||||
LoadCertificate (queue);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Unexpected handshake type ", (int)certificate[0]);
|
||||
delete[] certificate;
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "Can't connect to ", address);
|
||||
|
|
Loading…
Reference in a new issue