<commit_before>#include "DownloadManager.hpp"
#include "Common.hpp"
#include <QBuffer>
#include <quazip.h>

static const char AxioDLPublicKeyPEM[] =
"-----BEGIN PUBLIC KEY-----\n"
"<KEY>
"<KEY>
"<KEY>
"<KEY>"
"<KEY>"
"/<KEY>"
"<KEY>"
"-----END PUBLIC KEY-----\n";

static const QSslKey AxioDLPublicKey =
    QSslKey({AxioDLPublicKeyPEM}, QSsl::Rsa, QSsl::Pem, QSsl::PublicKey);

void DownloadManager::_validateCert(QNetworkReply* reply)
{
    QSslCertificate peerCert = reply->sslConfiguration().peerCertificate();
    if (peerCert.publicKey() != AxioDLPublicKey)
    {
        auto cn = peerCert.subjectInfo(QSslCertificate::CommonName);
        if (!cn.empty())
            setError(QNetworkReply::SslHandshakeFailedError,
                     QStringLiteral("Certificate pinning mismatch \"") + cn.first() + "\"");
        else
            setError(QNetworkReply::SslHandshakeFailedError,
                     QStringLiteral("Certificate pinning mismatch"));
        reply->abort();<commit_msg>Add edge certificate for pinning check<commit_after>#include "DownloadManager.hpp"
#include "Common.hpp"
#include <QBuffer>
#include <quazip.h>

static const char AxioDLPublicKeyPEM[] =
"-----BEGIN PUBLIC KEY-----\n"
"<KEY>
"<KEY>"
"<KEY>"
"<KEY>"
"<KEY>"
"/<KEY>"
"pwIDAQAB\n"
"-----END PUBLIC KEY-----\n";

static const QSslKey AxioDLPublicKey =
    QSslKey({AxioDLPublicKeyPEM}, QSsl::Rsa, QSsl::Pem, QSsl::PublicKey);

static const char AxioDLEdgePublicKeyPEM[] =
"-----BEGIN PUBLIC KEY-----\n"
"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE4a8ZLg3LRU0FiK6m8g2pT3qVBTMA\n"
"K2Uu5VGl7iamdGpUjynQ4uYWMx+WXf2Qkh7UZZgYvA6UeWHEs3M6ME8T6g==\n"
"-----END PUBLIC KEY-----\n";

static const QSslKey AxioDLEdgePublicKey =
    QSslKey({AxioDLEdgePublicKeyPEM}, QSsl::Ec, QSsl::Pem, QSsl::PublicKey);

void DownloadManager::_validateCert(QNetworkReply* reply)
{
    QSslCertificate peerCert = reply->sslConfiguration().peerCertificate();
    QSslKey peerKey = peerCert.publicKey();
    if (peerKey != AxioDLPublicKey && peerKey != AxioDLEdgePublicKey)
    {
        auto cn = peerCert.subjectInfo(QSslCertificate::CommonName);
        if (!cn.empty())
            setError(QNetworkReply::SslHandshakeFailedError,
                     QStringLiteral("Certificate pinning mismatch \"") + cn.first() + "\"");
        else
            setError(QNetworkReply::SslHandshakeFailedError,
                     QStringLiteral("Certificate pinning mismatch"));
        reply->abort();
{'fraction_non_alphanumeric': 0.15613534447615166, 'fraction_numerical': 0.008560945780676722, 'mean_word_length': 3.802348336594912, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2985198', 'n_tokens_mistral': 908, 'n_tokens_neox': 865, 'n_words': 145}