Commit d38c7bec authored by jan.koester's avatar jan.koester
Browse files

date support

parent b1a93c83
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -367,6 +367,34 @@ bool netplus::x509cert::checkValidity() {
    return true;
}

// ------------------------------------------------------------
// getNotAfter -- returns the notAfter time_t from the cert
// ------------------------------------------------------------
time_t netplus::x509cert::getNotAfter() {
    auto& r = root();
    if (r.children.empty() || r.children[0].children.size() < 5)
        return 0;

    ASN1Node* validity = nullptr;
    auto& tbs = r.children[0];

    for (auto& node : tbs.children) {
        if (node.tag == 0x30 && node.children.size() >= 2) {
            uint8_t t1 = node.children[0].tag;
            uint8_t t2 = node.children[1].tag;
            if ((t1 == 0x17 || t1 == 0x18) && (t2 == 0x17 || t2 == 0x18)) {
                validity = &node;
                break;
            }
        }
    }

    if (!validity) return 0;

    const ASN1Node& na = validity->children[1];
    return parseASN1Time(na.data, na.len, na.tag);
}

// ------------------------------------------------------------
// bytesToBigInt -- vector-based (keeps header compat)
// ------------------------------------------------------------
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ namespace netplus {
                           std::vector<std::vector<uint8_t>>& chain);

        bool checkValidity();
        time_t getNotAfter();
        bool extractPublicKey(netplus::rsa& outRsa);
        std::string getSubjectCN();
        std::vector<std::string> getSubjectAltNames();