4
4
#include " Packet.h"
5
5
#include " SSLLayer.h"
6
6
#include " SystemUtils.h"
7
+ #include " Logger.h"
7
8
#include < fstream>
8
9
#include < sstream>
9
10
@@ -344,34 +345,41 @@ PTF_TEST_CASE(SSLMultipleRecordParsing3Test)
344
345
PTF_ASSERT_EQUAL (certMsg->getNumOfCertificates (), 3 );
345
346
PTF_ASSERT_NULL (certMsg->getCertificate (1000 ));
346
347
347
- pcpp::SSLx509Certificate* cert = certMsg->getCertificate (0 );
348
- PTF_ASSERT_NOT_NULL (cert);
349
- PTF_ASSERT_TRUE (cert->allDataExists ());
350
- PTF_ASSERT_EQUAL (cert->getDataLength (), 1509 );
351
- std::string certBuffer (cert->getData (), cert->getData () + cert->getDataLength ());
352
- std::size_t pos = certBuffer.find (" LDAP Intermediate CA" );
353
- PTF_ASSERT_TRUE (pos != std::string::npos);
354
- pos = certBuffer.find (" Internal Development CA" );
355
- PTF_ASSERT_EQUAL (pos, std::string::npos, ptr);
356
- auto asn1Record = cert->getRootAsn1Record ();
357
- PTF_ASSERT_NOT_NULL (asn1Record);
358
- PTF_ASSERT_EQUAL (asn1Record->getSubRecords ().size (), 3 );
359
-
360
- cert = certMsg->getCertificate (1 );
361
- PTF_ASSERT_NOT_NULL (cert);
362
- PTF_ASSERT_TRUE (cert->allDataExists ());
363
- PTF_ASSERT_EQUAL (cert->getDataLength (), 1728 );
364
- certBuffer = std::string (cert->getData (), cert->getData () + cert->getDataLength ());
365
- pos = certBuffer.find (" Internal Development CA" );
366
- PTF_ASSERT_TRUE (pos != std::string::npos);
367
-
368
- cert = certMsg->getCertificate (2 );
369
- PTF_ASSERT_NOT_NULL (cert);
370
- PTF_ASSERT_TRUE (cert->allDataExists ());
371
- PTF_ASSERT_EQUAL (cert->getDataLength (), 1713 );
372
- certBuffer = std::string (cert->getData (), cert->getData () + cert->getDataLength ());
373
- pos = certBuffer.find (" Internal Development CA" );
374
- PTF_ASSERT_TRUE (pos != std::string::npos);
348
+ {
349
+ auto cert = certMsg->getCertificate (0 );
350
+ PTF_ASSERT_NOT_NULL (cert);
351
+ PTF_ASSERT_TRUE (cert->allDataExists ());
352
+ PTF_ASSERT_EQUAL (cert->getDataLength (), 1509 );
353
+ auto asn1Record = cert->getRootAsn1Record ();
354
+ PTF_ASSERT_NOT_NULL (asn1Record);
355
+ PTF_ASSERT_EQUAL (asn1Record->getSubRecords ().size (), 3 );
356
+ auto x509Cert = cert->getX509Certificate ();
357
+ PTF_ASSERT_EQUAL (
358
+ x509Cert->getIssuer ().toString (),
359
+ " C=US, ST=Washington, L=Seattle, O=Hubspan, Inc., OU=Development, CN=LDAP Intermediate CA, [email protected] " );
360
+ }
361
+
362
+ {
363
+ auto cert = certMsg->getCertificate (1 );
364
+ PTF_ASSERT_NOT_NULL (cert);
365
+ PTF_ASSERT_TRUE (cert->allDataExists ());
366
+ PTF_ASSERT_EQUAL (cert->getDataLength (), 1728 );
367
+ auto x509Cert = cert->getX509Certificate ();
368
+ PTF_ASSERT_EQUAL (
369
+ x509Cert->getSubject ().toString (),
370
+ " C=US, ST=Washington, L=Seattle, O=Hubspan, Inc., OU=Development, CN=LDAP Intermediate CA, [email protected] " );
371
+ }
372
+
373
+ {
374
+ auto cert = certMsg->getCertificate (2 );
375
+ PTF_ASSERT_NOT_NULL (cert);
376
+ PTF_ASSERT_TRUE (cert->allDataExists ());
377
+ PTF_ASSERT_EQUAL (cert->getDataLength (), 1713 );
378
+ auto x509Cert = cert->getX509Certificate ();
379
+ PTF_ASSERT_EQUAL (
380
+ x509Cert->getSubject ().toString (),
381
+ " C=US, ST=Washington, O=Hubspan, Inc., OU=Development, CN=Internal Development CA, [email protected] " );
382
+ }
375
383
376
384
pcpp::SSLCertificateRequestMessage* certReqMsg =
377
385
handshakeLayer->getHandshakeMessageOfType <pcpp::SSLCertificateRequestMessage>();
@@ -482,6 +490,10 @@ PTF_TEST_CASE(SSLPartialCertificateParseTest)
482
490
pcpp::SSLx509Certificate* cert = certMsg->getCertificate (0 );
483
491
PTF_ASSERT_FALSE (cert->allDataExists ());
484
492
PTF_ASSERT_EQUAL (cert->getDataLength (), 1266 );
493
+ pcpp::Logger::getInstance ().suppressLogs ();
494
+ PTF_ASSERT_NULL (cert->getX509Certificate ());
495
+ PTF_ASSERT_NULL (cert->getRootAsn1Record ());
496
+ pcpp::Logger::getInstance ().enableLogs ();
485
497
486
498
READ_FILE_AND_CREATE_PACKET (2 , " PacketExamples/SSL-PartialCertificate2.dat" );
487
499
@@ -499,6 +511,10 @@ PTF_TEST_CASE(SSLPartialCertificateParseTest)
499
511
cert = certMsg->getCertificate (0 );
500
512
PTF_ASSERT_FALSE (cert->allDataExists ());
501
513
PTF_ASSERT_EQUAL (cert->getDataLength (), 1268 );
514
+ pcpp::Logger::getInstance ().suppressLogs ();
515
+ PTF_ASSERT_NULL (cert->getX509Certificate ());
516
+ PTF_ASSERT_NULL (cert->getRootAsn1Record ());
517
+ pcpp::Logger::getInstance ().enableLogs ();
502
518
} // SSLPartialCertificateParseTest
503
519
504
520
PTF_TEST_CASE (SSLNewSessionTicketParseTest)
0 commit comments