Loading src/crypto/x509.cpp +33 −0 Changes for src/crypto/x509.cpp: 33 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include <string> #include <vector> #include "base64.h" #include "x509.h" netplus::ASN1Node::ASN1Node(const ASN1Node &src){ Loading Loading @@ -455,3 +456,35 @@ std::vector<std::string> netplus::x509cert::getSubjectAltNames() { } return dnsNames; } std::vector<uint8_t> netplus::x509cert::pemCertToDer(const std::string& pem) { const std::string begin = "-----BEGIN CERTIFICATE-----"; const std::string end = "-----END CERTIFICATE-----"; auto b = pem.find(begin); if (b == std::string::npos) throw std::runtime_error("PEM: missing BEGIN"); b += begin.size(); auto e = pem.find(end, b); if (e == std::string::npos) throw std::runtime_error("PEM: missing END"); std::string body = pem.substr(b, e - b); // keep only base64 chars std::string b64; b64.reserve(body.size()); for (unsigned char c : body) { if (std::isalnum(c) || c == '+' || c == '/' || c == '=') b64.push_back(static_cast<char>(c)); } netplus::base64 dec; dec << b64; // Base64 → Binär return dec; // implizite Konvertierung zu std::vector<uint8_t> } src/crypto/x509.h +1 −1 Changes for src/crypto/x509.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ namespace netplus { std::string getSubjectCN(); bool extractPublicKey(netplus::rsa& outRsa); std::vector<uint8_t> pemCertToDer(const std::string& pem); std::vector<std::string> getSubjectAltNames(); private: Loading Loading
src/crypto/x509.cpp +33 −0 Changes for src/crypto/x509.cpp: 33 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include <string> #include <vector> #include "base64.h" #include "x509.h" netplus::ASN1Node::ASN1Node(const ASN1Node &src){ Loading Loading @@ -455,3 +456,35 @@ std::vector<std::string> netplus::x509cert::getSubjectAltNames() { } return dnsNames; } std::vector<uint8_t> netplus::x509cert::pemCertToDer(const std::string& pem) { const std::string begin = "-----BEGIN CERTIFICATE-----"; const std::string end = "-----END CERTIFICATE-----"; auto b = pem.find(begin); if (b == std::string::npos) throw std::runtime_error("PEM: missing BEGIN"); b += begin.size(); auto e = pem.find(end, b); if (e == std::string::npos) throw std::runtime_error("PEM: missing END"); std::string body = pem.substr(b, e - b); // keep only base64 chars std::string b64; b64.reserve(body.size()); for (unsigned char c : body) { if (std::isalnum(c) || c == '+' || c == '/' || c == '=') b64.push_back(static_cast<char>(c)); } netplus::base64 dec; dec << b64; // Base64 → Binär return dec; // implizite Konvertierung zu std::vector<uint8_t> }
src/crypto/x509.h +1 −1 Changes for src/crypto/x509.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ namespace netplus { std::string getSubjectCN(); bool extractPublicKey(netplus::rsa& outRsa); std::vector<uint8_t> pemCertToDer(const std::string& pem); std::vector<std::string> getSubjectAltNames(); private: Loading