Skip to content

Commit a05ab8e

Browse files
authored
Add X509 certificate decoder (#1871)
* Initial implementation * - Add RelativeDistinguishedName::Value parsing - Add format options for validity fields * - Move internal implementation to its own namespace - Implement the rest of the methods * - Improve the API - Add tests * - Update `X509Algorithm` values - Add more values to `X520DistinguishedName` - Add more values to `X509ExtensionType` - Add `X509SerialNumber` class to parse serial numbers - Add tests - Add a script to generate certs * - Add methods to catch ASN.1 read exceptions and throw an appropriate X509 exception - Add invalid tests * - Run clang-format - Add to README.md * Add doxygen documentation * Add doxygen documentation for enum values * Add missing doxygen documentation * Add remaining doxygen documentation * Add tests for the ASN.1 changes * Fmt * Fix variable type * - Address build errors on MSVC - Fix doxygen warning * Fix most of the memory leaks in MSVC * Fix remaining memory leaks * Skip long expiration test in MinGW 32-bit * Address PR comments * Address PR comment
1 parent 01731d8 commit a05ab8e

22 files changed

+2551
-2
lines changed

Packet++/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ add_library(
6767
src/VxlanLayer.cpp
6868
src/WakeOnLanLayer.cpp
6969
src/WireGuardLayer.cpp
70+
src/X509Decoder.cpp
7071
# Force hash-library pcapng to be link fully static
7172
)
7273

@@ -140,6 +141,7 @@ set(
140141
header/VxlanLayer.h
141142
header/WakeOnLanLayer.h
142143
header/WireGuardLayer.h
144+
header/X509Decoder.h
143145
)
144146

145147
# Don't use set_target_properties CMake limit to 50 elements
@@ -153,9 +155,10 @@ target_include_directories(
153155
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/header>
154156
$<INSTALL_INTERFACE:include/pcapplusplus>
155157
$<INSTALL_INTERFACE:include>
156-
# Don't link with hash-library nor EndianPortable as they won't be exported
158+
# Don't link with hash-library, EndianPortable and json as they won't be exported
157159
PRIVATE $<TARGET_PROPERTY:hash-library,INCLUDE_DIRECTORIES>
158160
PRIVATE $<TARGET_PROPERTY:EndianPortable,INTERFACE_INCLUDE_DIRECTORIES>
161+
PRIVATE $<TARGET_PROPERTY:json,INTERFACE_INCLUDE_DIRECTORIES>
159162
)
160163

161164
target_link_libraries(Packet++ PUBLIC Common++)

Packet++/header/Asn1Codec.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,13 @@ namespace pcpp
850850
return m_Value.toString();
851851
};
852852

853+
/// @return The byte vector value of this record
854+
std::vector<uint8_t> getVecValue()
855+
{
856+
decodeValueIfNeeded();
857+
return m_Value.toBytes();
858+
}
859+
853860
protected:
854861
void decodeValue(uint8_t const* data, bool lazy) override;
855862
std::vector<uint8_t> encodeValue() const override;

0 commit comments

Comments
 (0)