| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslcertificate_openssl.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | static QMap<QByteArray, QString> _q_mapFromX509Name(X509_NAME *name); | - | ||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | bool QSslCertificate::operator==(const QSslCertificate &other) const | - | ||||||||||||||||||||||||
| 9 | { | - | ||||||||||||||||||||||||
| 10 | if (d == other.d
| 51-7118 | ||||||||||||||||||||||||
| 11 | return executed 51 times by 4 tests: true;return true;Executed by:
executed 51 times by 4 tests: return true;Executed by:
| 51 | ||||||||||||||||||||||||
| 12 | if (d->null
| 27-7044 | ||||||||||||||||||||||||
| 13 | return executed 47 times by 3 tests: true;return true;Executed by:
executed 47 times by 3 tests: return true;Executed by:
| 47 | ||||||||||||||||||||||||
| 14 | if (d->x509
| 4-7044 | ||||||||||||||||||||||||
| 15 | return executed 7040 times by 3 tests: q_X509_cmp(d->x509, other.d->x509) == 0;return q_X509_cmp(d->x509, other.d->x509) == 0;Executed by:
executed 7040 times by 3 tests: return q_X509_cmp(d->x509, other.d->x509) == 0;Executed by:
| 7040 | ||||||||||||||||||||||||
| 16 | return executed 31 times by 2 tests: false;return false;Executed by:
executed 31 times by 2 tests: return false;Executed by:
| 31 | ||||||||||||||||||||||||
| 17 | } | - | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | uint qHash(const QSslCertificate &key, uint seed) noexcept | - | ||||||||||||||||||||||||
| 20 | { | - | ||||||||||||||||||||||||
| 21 | if (X509 * const x509 = key.d->x509
| 0-4 | ||||||||||||||||||||||||
| 22 | (void)q_X509_cmp(x509, x509); | - | ||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | return never executed: qHashBits(x509->sha1_hash, 20, seed);return qHashBits(x509->sha1_hash, 20, seed);never executed: return qHashBits(x509->sha1_hash, 20, seed); | 0 | ||||||||||||||||||||||||
| 25 | } else { | - | ||||||||||||||||||||||||
| 26 | return executed 4 times by 2 tests: seed;return seed;Executed by:
executed 4 times by 2 tests: return seed;Executed by:
| 4 | ||||||||||||||||||||||||
| 27 | } | - | ||||||||||||||||||||||||
| 28 | } | - | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | bool QSslCertificate::isNull() const | - | ||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||
| 32 | return executed 3707 times by 9 tests: d->null;return d->null;Executed by:
executed 3707 times by 9 tests: return d->null;Executed by:
| 3707 | ||||||||||||||||||||||||
| 33 | } | - | ||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||
| 35 | bool QSslCertificate::isSelfSigned() const | - | ||||||||||||||||||||||||
| 36 | { | - | ||||||||||||||||||||||||
| 37 | if (!d->x509
| 1-2 | ||||||||||||||||||||||||
| 38 | return executed 1 time by 1 test: false;return false;Executed by:
executed 1 time by 1 test: return false;Executed by:
| 1 | ||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||
| 40 | return executed 2 times by 1 test: (q_X509_check_issued(d->x509, d->x509) == 0);return (q_X509_check_issued(d->x509, d->x509) == 0);Executed by:
executed 2 times by 1 test: return (q_X509_check_issued(d->x509, d->x509) == 0);Executed by:
| 2 | ||||||||||||||||||||||||
| 41 | } | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | QByteArray QSslCertificate::version() const | - | ||||||||||||||||||||||||
| 44 | { | - | ||||||||||||||||||||||||
| 45 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 46 | if (d->versionString.isEmpty()
| 2-64 | ||||||||||||||||||||||||
| 47 | d->versionString = executed 13 times by 1 test: d->versionString = QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1);Executed by:
| 13 | ||||||||||||||||||||||||
| 48 | QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1); executed 13 times by 1 test: d->versionString = QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1);Executed by:
| 13 | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | return executed 79 times by 1 test: d->versionString;return d->versionString;Executed by:
executed 79 times by 1 test: return d->versionString;Executed by:
| 79 | ||||||||||||||||||||||||
| 51 | } | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | QByteArray QSslCertificate::serialNumber() const | - | ||||||||||||||||||||||||
| 54 | { | - | ||||||||||||||||||||||||
| 55 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 56 | if (d->serialNumberString.isEmpty()
| 37-16564 | ||||||||||||||||||||||||
| 57 | ASN1_INTEGER *serialNumber = d->x509->cert_info->serialNumber; | - | ||||||||||||||||||||||||
| 58 | QByteArray hexString; | - | ||||||||||||||||||||||||
| 59 | hexString.reserve(serialNumber->length * 3); | - | ||||||||||||||||||||||||
| 60 | for (int a = 0; a < serialNumber->length
| 453-3564 | ||||||||||||||||||||||||
| 61 | hexString += QByteArray::number(serialNumber->data[a], 16).rightJustified(2, '0'); | - | ||||||||||||||||||||||||
| 62 | hexString += ':'; | - | ||||||||||||||||||||||||
| 63 | } executed 3564 times by 8 tests: end of blockExecuted by:
| 3564 | ||||||||||||||||||||||||
| 64 | hexString.chop(1); | - | ||||||||||||||||||||||||
| 65 | d->serialNumberString = hexString; | - | ||||||||||||||||||||||||
| 66 | } executed 453 times by 8 tests: end of blockExecuted by:
| 453 | ||||||||||||||||||||||||
| 67 | return executed 17054 times by 8 tests: d->serialNumberString;return d->serialNumberString;Executed by:
executed 17054 times by 8 tests: return d->serialNumberString;Executed by:
| 17054 | ||||||||||||||||||||||||
| 68 | } | - | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | QStringList QSslCertificate::issuerInfo(SubjectInfo info) const | - | ||||||||||||||||||||||||
| 71 | { | - | ||||||||||||||||||||||||
| 72 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | if (d->issuerInfo.isEmpty()
| 1-213 | ||||||||||||||||||||||||
| 75 | d->issuerInfo = executed 11 times by 1 test: d->issuerInfo = _q_mapFromX509Name(q_X509_get_issuer_name(d->x509));Executed by:
| 11 | ||||||||||||||||||||||||
| 76 | _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); executed 11 times by 1 test: d->issuerInfo = _q_mapFromX509Name(q_X509_get_issuer_name(d->x509));Executed by:
| 11 | ||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | return executed 225 times by 1 test: d->issuerInfo.values(d->subjectInfoToString(info));return d->issuerInfo.values(d->subjectInfoToString(info));Executed by:
executed 225 times by 1 test: return d->issuerInfo.values(d->subjectInfoToString(info));Executed by:
| 225 | ||||||||||||||||||||||||
| 79 | } | - | ||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 | QStringList QSslCertificate::issuerInfo(const QByteArray &attribute) const | - | ||||||||||||||||||||||||
| 82 | { | - | ||||||||||||||||||||||||
| 83 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | if (d->issuerInfo.isEmpty()
| 0-6 | ||||||||||||||||||||||||
| 86 | d->issuerInfo = executed 1 time by 1 test: d->issuerInfo = _q_mapFromX509Name(q_X509_get_issuer_name(d->x509));Executed by:
| 1 | ||||||||||||||||||||||||
| 87 | _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); executed 1 time by 1 test: d->issuerInfo = _q_mapFromX509Name(q_X509_get_issuer_name(d->x509));Executed by:
| 1 | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | return executed 7 times by 1 test: d->issuerInfo.values(attribute);return d->issuerInfo.values(attribute);Executed by:
executed 7 times by 1 test: return d->issuerInfo.values(attribute);Executed by:
| 7 | ||||||||||||||||||||||||
| 90 | } | - | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | QStringList QSslCertificate::subjectInfo(SubjectInfo info) const | - | ||||||||||||||||||||||||
| 93 | { | - | ||||||||||||||||||||||||
| 94 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | if (d->subjectInfo.isEmpty()
| 1-417 | ||||||||||||||||||||||||
| 97 | d->subjectInfo = executed 416 times by 8 tests: d->subjectInfo = _q_mapFromX509Name(q_X509_get_subject_name(d->x509));Executed by:
| 416 | ||||||||||||||||||||||||
| 98 | _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); executed 416 times by 8 tests: d->subjectInfo = _q_mapFromX509Name(q_X509_get_subject_name(d->x509));Executed by:
| 416 | ||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||
| 100 | return executed 631 times by 8 tests: d->subjectInfo.values(d->subjectInfoToString(info));return d->subjectInfo.values(d->subjectInfoToString(info));Executed by:
executed 631 times by 8 tests: return d->subjectInfo.values(d->subjectInfoToString(info));Executed by:
| 631 | ||||||||||||||||||||||||
| 101 | } | - | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | QStringList QSslCertificate::subjectInfo(const QByteArray &attribute) const | - | ||||||||||||||||||||||||
| 104 | { | - | ||||||||||||||||||||||||
| 105 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | if (d->subjectInfo.isEmpty()
| 0-9 | ||||||||||||||||||||||||
| 108 | d->subjectInfo = executed 2 times by 1 test: d->subjectInfo = _q_mapFromX509Name(q_X509_get_subject_name(d->x509));Executed by:
| 2 | ||||||||||||||||||||||||
| 109 | _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); executed 2 times by 1 test: d->subjectInfo = _q_mapFromX509Name(q_X509_get_subject_name(d->x509));Executed by:
| 2 | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | return executed 11 times by 1 test: d->subjectInfo.values(attribute);return d->subjectInfo.values(attribute);Executed by:
executed 11 times by 1 test: return d->subjectInfo.values(attribute);Executed by:
| 11 | ||||||||||||||||||||||||
| 112 | } | - | ||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | QList<QByteArray> QSslCertificate::subjectInfoAttributes() const | - | ||||||||||||||||||||||||
| 115 | { | - | ||||||||||||||||||||||||
| 116 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | if (d->subjectInfo.isEmpty()
| 0-2 | ||||||||||||||||||||||||
| 119 | d->subjectInfo = executed 2 times by 1 test: d->subjectInfo = _q_mapFromX509Name(q_X509_get_subject_name(d->x509));Executed by:
| 2 | ||||||||||||||||||||||||
| 120 | _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); executed 2 times by 1 test: d->subjectInfo = _q_mapFromX509Name(q_X509_get_subject_name(d->x509));Executed by:
| 2 | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | return executed 4 times by 1 test: d->subjectInfo.uniqueKeys();return d->subjectInfo.uniqueKeys();Executed by:
executed 4 times by 1 test: return d->subjectInfo.uniqueKeys();Executed by:
| 4 | ||||||||||||||||||||||||
| 123 | } | - | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | QList<QByteArray> QSslCertificate::issuerInfoAttributes() const | - | ||||||||||||||||||||||||
| 126 | { | - | ||||||||||||||||||||||||
| 127 | QMutexLocker lock(QMutexPool::globalInstanceGet(d.data())); | - | ||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | if (d->issuerInfo.isEmpty()
| 0-2 | ||||||||||||||||||||||||
| 130 | d->issuerInfo = never executed: d->issuerInfo = _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); | 0 | ||||||||||||||||||||||||
| 131 | _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); never executed: d->issuerInfo = _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); | 0 | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | return executed 2 times by 1 test: d->issuerInfo.uniqueKeys();return d->issuerInfo.uniqueKeys();Executed by:
executed 2 times by 1 test: return d->issuerInfo.uniqueKeys();Executed by:
| 2 | ||||||||||||||||||||||||
| 134 | } | - | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | QMultiMap<QSsl::AlternativeNameEntryType, QString> QSslCertificate::subjectAlternativeNames() const | - | ||||||||||||||||||||||||
| 137 | { | - | ||||||||||||||||||||||||
| 138 | QMultiMap<QSsl::AlternativeNameEntryType, QString> result; | - | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | if (!d->x509
| 1-102 | ||||||||||||||||||||||||
| 141 | return executed 1 time by 1 test: result;return result;Executed by:
executed 1 time by 1 test: return result;Executed by:
| 1 | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | struct stack_st_GENERAL_NAME *altNames = (struct stack_st_GENERAL_NAME*)q_X509_get_ext_d2i(d->x509, 85, 0, 0); | - | ||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | if (altNames
| 11-91 | ||||||||||||||||||||||||
| 146 | for (int i = 0; i < ((int (*)(const struct stack_st_GENERAL_NAME *))q_sk_num)((altNames))
| 11-31 | ||||||||||||||||||||||||
| 147 | const GENERAL_NAME *genName = ((GENERAL_NAME * (*)(const struct stack_st_GENERAL_NAME *, int))q_sk_value)((altNames), (i)); | - | ||||||||||||||||||||||||
| 148 | if (genName->type != 2
| 0-20 | ||||||||||||||||||||||||
| 149 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | int len = q_ASN1_STRING_length(genName->d.ia5); | - | ||||||||||||||||||||||||
| 152 | if (len < 0
| 0-31 | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 155 | } | - | ||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | const char *altNameStr = reinterpret_cast<const char *>(q_ASN1_STRING_data(genName->d.ia5)); | - | ||||||||||||||||||||||||
| 158 | const QString altName = QString::fromLatin1(altNameStr, len); | - | ||||||||||||||||||||||||
| 159 | if (genName->type == 2
| 11-20 | ||||||||||||||||||||||||
| 160 | result.insert(QSsl::DnsEntry, altName); executed 11 times by 1 test: result.insert(QSsl::DnsEntry, altName);Executed by:
| 11 | ||||||||||||||||||||||||
| 161 | else if (genName->type == 1
| 0-20 | ||||||||||||||||||||||||
| 162 | result.insert(QSsl::EmailEntry, altName); executed 20 times by 1 test: result.insert(QSsl::EmailEntry, altName);Executed by:
| 20 | ||||||||||||||||||||||||
| 163 | } executed 31 times by 1 test: end of blockExecuted by:
| 31 | ||||||||||||||||||||||||
| 164 | q_sk_pop_free((STACK*)altNames, reinterpret_cast<void(*)(void*)>(q_sk_free)); | - | ||||||||||||||||||||||||
| 165 | } executed 11 times by 1 test: end of blockExecuted by:
| 11 | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | return executed 102 times by 3 tests: result;return result;Executed by:
executed 102 times by 3 tests: return result;Executed by:
| 102 | ||||||||||||||||||||||||
| 168 | } | - | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | QDateTime QSslCertificate::effectiveDate() const | - | ||||||||||||||||||||||||
| 171 | { | - | ||||||||||||||||||||||||
| 172 | return executed 41 times by 1 test: d->notValidBefore;return d->notValidBefore;Executed by:
executed 41 times by 1 test: return d->notValidBefore;Executed by:
| 41 | ||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | QDateTime QSslCertificate::expiryDate() const | - | ||||||||||||||||||||||||
| 176 | { | - | ||||||||||||||||||||||||
| 177 | return executed 57430 times by 4 tests: d->notValidAfter;return d->notValidAfter;Executed by:
executed 57430 times by 4 tests: return d->notValidAfter;Executed by:
| 57430 | ||||||||||||||||||||||||
| 178 | } | - | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | Qt::HANDLE QSslCertificate::handle() const | - | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | return executed 53884 times by 4 tests: Qt::HANDLE(d->x509);return Qt::HANDLE(d->x509);Executed by:
executed 53884 times by 4 tests: return Qt::HANDLE(d->x509);Executed by:
| 53884 | ||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | QSslKey QSslCertificate::publicKey() const | - | ||||||||||||||||||||||||
| 186 | { | - | ||||||||||||||||||||||||
| 187 | if (!d->x509
| 0-8 | ||||||||||||||||||||||||
| 188 | return never executed: QSslKey();return QSslKey();never executed: return QSslKey(); | 0 | ||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||
| 190 | QSslKey key; | - | ||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||
| 192 | key.d->type = QSsl::PublicKey; | - | ||||||||||||||||||||||||
| 193 | X509_PUBKEY *xkey = d->x509->cert_info->key; | - | ||||||||||||||||||||||||
| 194 | EVP_PKEY *pkey = q_X509_PUBKEY_get(xkey); | - | ||||||||||||||||||||||||
| 195 | ((!(pkey)) ? qt_assert("pkey",__FILE__,240) : qt_noop()); | - | ||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||
| 197 | if (q_EVP_PKEY_type(pkey->type) == 6
| 2-6 | ||||||||||||||||||||||||
| 198 | key.d->rsa = q_EVP_PKEY_get1_RSA(pkey); | - | ||||||||||||||||||||||||
| 199 | key.d->algorithm = QSsl::Rsa; | - | ||||||||||||||||||||||||
| 200 | key.d->isNull = false; | - | ||||||||||||||||||||||||
| 201 | } executed 6 times by 1 test: else if (q_EVP_PKEY_type(pkey->type) == 116end of blockExecuted by:
| 1-6 | ||||||||||||||||||||||||
| 202 | key.d->dsa = q_EVP_PKEY_get1_DSA(pkey); | - | ||||||||||||||||||||||||
| 203 | key.d->algorithm = QSsl::Dsa; | - | ||||||||||||||||||||||||
| 204 | key.d->isNull = false; | - | ||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||
| 206 | } executed 1 time by 1 test: else if (q_EVP_PKEY_type(pkey->type) == 408end of blockExecuted by:
| 0-1 | ||||||||||||||||||||||||
| 207 | key.d->ec = q_EVP_PKEY_get1_EC_KEY(pkey); | - | ||||||||||||||||||||||||
| 208 | key.d->algorithm = QSsl::Ec; | - | ||||||||||||||||||||||||
| 209 | key.d->isNull = false; | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | } executed 1 time by 1 test: else if (q_EVP_PKEY_type(pkey->type) == 28end of blockExecuted by:
| 0-1 | ||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||
| 217 | q_EVP_PKEY_free(pkey); | - | ||||||||||||||||||||||||
| 218 | return executed 8 times by 1 test: key;return key;Executed by:
executed 8 times by 1 test: return key;Executed by:
| 8 | ||||||||||||||||||||||||
| 219 | } | - | ||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | static QVariant x509UnknownExtensionToValue(X509_EXTENSION *ext) | - | ||||||||||||||||||||||||
| 225 | { | - | ||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | X509V3_EXT_METHOD *meth = const_cast<X509V3_EXT_METHOD *>(q_X509V3_EXT_get(ext)); | - | ||||||||||||||||||||||||
| 231 | if (!meth
| 1-9 | ||||||||||||||||||||||||
| 232 | ASN1_OCTET_STRING *value = q_X509_EXTENSION_get_data(ext); | - | ||||||||||||||||||||||||
| 233 | QByteArray result( reinterpret_cast<const char *>(q_ASN1_STRING_data(value)), | - | ||||||||||||||||||||||||
| 234 | q_ASN1_STRING_length(value)); | - | ||||||||||||||||||||||||
| 235 | return executed 1 time by 1 test: result;return result;Executed by:
executed 1 time by 1 test: return result;Executed by:
| 1 | ||||||||||||||||||||||||
| 236 | } | - | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||
| 239 | void *ext_internal = q_X509V3_EXT_d2i(ext); | - | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||
| 242 | if (meth->i2v
| 0-5 | ||||||||||||||||||||||||
| 243 | struct stack_st_CONF_VALUE *val = meth->i2v(meth, ext_internal, 0); | - | ||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||
| 245 | QVariantMap map; | - | ||||||||||||||||||||||||
| 246 | QVariantList list; | - | ||||||||||||||||||||||||
| 247 | bool isMap = false; | - | ||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | for (int j = 0; j < ((int (*)(const struct stack_st_CONF_VALUE *))q_sk_num)(val)
| 5-12 | ||||||||||||||||||||||||
| 250 | CONF_VALUE *nval = ((CONF_VALUE * (*)(const struct stack_st_CONF_VALUE *, int))q_sk_value)(val, j); | - | ||||||||||||||||||||||||
| 251 | if (nval->name
| 2-6 | ||||||||||||||||||||||||
| 252 | isMap = true; | - | ||||||||||||||||||||||||
| 253 | map[QString::fromUtf8(nval->name)] = QString::fromUtf8(nval->value); | - | ||||||||||||||||||||||||
| 254 | } executed 2 times by 1 test: else if (nval->nameend of blockExecuted by:
| 2-6 | ||||||||||||||||||||||||
| 255 | list << QString::fromUtf8(nval->name); | - | ||||||||||||||||||||||||
| 256 | } executed 4 times by 1 test: else if (nval->valueend of blockExecuted by:
| 0-6 | ||||||||||||||||||||||||
| 257 | list << QString::fromUtf8(nval->value); | - | ||||||||||||||||||||||||
| 258 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 259 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | if (isMap
| 1-4 | ||||||||||||||||||||||||
| 262 | return executed 1 time by 1 test: map;return map;Executed by:
executed 1 time by 1 test: return map;Executed by:
| 1 | ||||||||||||||||||||||||
| 263 | else | - | ||||||||||||||||||||||||
| 264 | return executed 4 times by 1 test: list;return list;Executed by:
executed 4 times by 1 test: return list;Executed by:
| 4 | ||||||||||||||||||||||||
| 265 | } else if (meth->i2s
| 0-4 | ||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | QVariant result(QString::fromUtf8(meth->i2s(meth, ext_internal))); | - | ||||||||||||||||||||||||
| 268 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 269 | } else if (meth->i2r
| 0-4 | ||||||||||||||||||||||||
| 270 | QByteArray result; | - | ||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | BIO *bio = q_BIO_new(q_BIO_s_mem()); | - | ||||||||||||||||||||||||
| 273 | if (!bio
| 0-4 | ||||||||||||||||||||||||
| 274 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||
| 276 | meth->i2r(meth, ext_internal, bio, 0); | - | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | char *bio_buffer; | - | ||||||||||||||||||||||||
| 279 | long bio_size = (int)q_BIO_ctrl(bio,3,0,(char *)&bio_buffer); | - | ||||||||||||||||||||||||
| 280 | result = QByteArray(bio_buffer, bio_size); | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | q_BIO_free(bio); | - | ||||||||||||||||||||||||
| 283 | return executed 4 times by 1 test: result;return result;Executed by:
executed 4 times by 1 test: return result;Executed by:
| 4 | ||||||||||||||||||||||||
| 284 | } | - | ||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | return never executed: QVariant();return QVariant();never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
| 287 | } | - | ||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | static QVariant x509ExtensionToValue(X509_EXTENSION *ext) | - | ||||||||||||||||||||||||
| 295 | { | - | ||||||||||||||||||||||||
| 296 | ASN1_OBJECT *obj = q_X509_EXTENSION_get_object(ext); | - | ||||||||||||||||||||||||
| 297 | int nid = q_OBJ_obj2nid(obj); | - | ||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||
| 299 | switch (nid) { | - | ||||||||||||||||||||||||
| 300 | case executed 2 times by 1 test: 87:case 87:Executed by:
executed 2 times by 1 test: case 87:Executed by:
| 2 | ||||||||||||||||||||||||
| 301 | { | - | ||||||||||||||||||||||||
| 302 | BASIC_CONSTRAINTS *basic = reinterpret_cast<BASIC_CONSTRAINTS *>(q_X509V3_EXT_d2i(ext)); | - | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | QVariantMap result; | - | ||||||||||||||||||||||||
| 305 | result[QLatin1String("ca")] = basic->ca
| 0-2 | ||||||||||||||||||||||||
| 306 | if (basic->pathlen
| 0-2 | ||||||||||||||||||||||||
| 307 | result[QLatin1String("pathLenConstraint")] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen); never executed: result[QLatin1String("pathLenConstraint")] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen); | 0 | ||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||
| 309 | q_BASIC_CONSTRAINTS_free(basic); | - | ||||||||||||||||||||||||
| 310 | return executed 2 times by 1 test: result;return result;Executed by:
executed 2 times by 1 test: return result;Executed by:
| 2 | ||||||||||||||||||||||||
| 311 | } | - | ||||||||||||||||||||||||
| 312 | break; dead code: break; | - | ||||||||||||||||||||||||
| 313 | case executed 2 times by 1 test: 177:case 177:Executed by:
executed 2 times by 1 test: case 177:Executed by:
| 2 | ||||||||||||||||||||||||
| 314 | { | - | ||||||||||||||||||||||||
| 315 | AUTHORITY_INFO_ACCESS *info = reinterpret_cast<AUTHORITY_INFO_ACCESS *>(q_X509V3_EXT_d2i(ext)); | - | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | QVariantMap result; | - | ||||||||||||||||||||||||
| 318 | for (int i=0; i < ((int (*)(const struct stack_st_ACCESS_DESCRIPTION *))q_sk_num)(info)
| 2-4 | ||||||||||||||||||||||||
| 319 | ACCESS_DESCRIPTION *ad = ((ACCESS_DESCRIPTION * (*)(const struct stack_st_ACCESS_DESCRIPTION *, int))q_sk_value)(info, i); | - | ||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | GENERAL_NAME *name = ad->location; | - | ||||||||||||||||||||||||
| 322 | if (name->type == 6
| 0-4 | ||||||||||||||||||||||||
| 323 | int len = q_ASN1_STRING_length(name->d.uniformResourceIdentifier); | - | ||||||||||||||||||||||||
| 324 | if (len < 0
| 0-4 | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 327 | } | - | ||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | const char *uriStr = reinterpret_cast<const char *>(q_ASN1_STRING_data(name->d.uniformResourceIdentifier)); | - | ||||||||||||||||||||||||
| 330 | const QString uri = QString::fromUtf8(uriStr, len); | - | ||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | result[QString::fromUtf8(QSslCertificatePrivate::asn1ObjectName(ad->method))] = uri; | - | ||||||||||||||||||||||||
| 333 | } executed 4 times by 1 test: else {end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 334 | for (bool qt_category_enabled = lcSsl().isWarningEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 379, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning() << "Strange location type" << name->type; | 0 | ||||||||||||||||||||||||
| 335 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 336 | } | - | ||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | q_sk_pop_free((_STACK*)info, reinterpret_cast<void(*)(void*)>(q_sk_free)); | - | ||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | return executed 2 times by 1 test: result;return result;Executed by:
executed 2 times by 1 test: return result;Executed by:
| 2 | ||||||||||||||||||||||||
| 344 | } | - | ||||||||||||||||||||||||
| 345 | break; dead code: break; | - | ||||||||||||||||||||||||
| 346 | case executed 2 times by 1 test: 82:case 82:Executed by:
executed 2 times by 1 test: case 82:Executed by:
| 2 | ||||||||||||||||||||||||
| 347 | { | - | ||||||||||||||||||||||||
| 348 | void *ext_internal = q_X509V3_EXT_d2i(ext); | - | ||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | X509V3_EXT_METHOD *meth = const_cast<X509V3_EXT_METHOD *>(q_X509V3_EXT_get(ext)); | - | ||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | return executed 2 times by 1 test: QVariant(QString::fromUtf8(meth->i2s(meth, ext_internal)));return QVariant(QString::fromUtf8(meth->i2s(meth, ext_internal)));Executed by:
executed 2 times by 1 test: return QVariant(QString::fromUtf8(meth->i2s(meth, ext_internal)));Executed by:
| 2 | ||||||||||||||||||||||||
| 356 | } | - | ||||||||||||||||||||||||
| 357 | break; dead code: break; | - | ||||||||||||||||||||||||
| 358 | case executed 2 times by 1 test: 90:case 90:Executed by:
executed 2 times by 1 test: case 90:Executed by:
| 2 | ||||||||||||||||||||||||
| 359 | { | - | ||||||||||||||||||||||||
| 360 | AUTHORITY_KEYID *auth_key = reinterpret_cast<AUTHORITY_KEYID *>(q_X509V3_EXT_d2i(ext)); | - | ||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | QVariantMap result; | - | ||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | if (auth_key->keyid
| 0-2 | ||||||||||||||||||||||||
| 366 | QByteArray keyid(reinterpret_cast<const char *>(auth_key->keyid->data), | - | ||||||||||||||||||||||||
| 367 | auth_key->keyid->length); | - | ||||||||||||||||||||||||
| 368 | result[QLatin1String("keyid")] = keyid.toHex(); | - | ||||||||||||||||||||||||
| 369 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | if (auth_key->serial
| 0-2 | ||||||||||||||||||||||||
| 376 | result[QLatin1String("serial")] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial); never executed: result[QLatin1String("serial")] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial); | 0 | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | q_AUTHORITY_KEYID_free(auth_key); | - | ||||||||||||||||||||||||
| 379 | return executed 2 times by 1 test: result;return result;Executed by:
executed 2 times by 1 test: return result;Executed by:
| 2 | ||||||||||||||||||||||||
| 380 | } | - | ||||||||||||||||||||||||
| 381 | break; dead code: break; | - | ||||||||||||||||||||||||
| 382 | } | - | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | return executed 10 times by 1 test: QVariant();return QVariant();Executed by:
executed 10 times by 1 test: return QVariant();Executed by:
| 10 | ||||||||||||||||||||||||
| 385 | } | - | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | QSslCertificateExtension QSslCertificatePrivate::convertExtension(X509_EXTENSION *ext) | - | ||||||||||||||||||||||||
| 388 | { | - | ||||||||||||||||||||||||
| 389 | QSslCertificateExtension result; | - | ||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | ASN1_OBJECT *obj = q_X509_EXTENSION_get_object(ext); | - | ||||||||||||||||||||||||
| 392 | QByteArray oid = QSslCertificatePrivate::asn1ObjectId(obj); | - | ||||||||||||||||||||||||
| 393 | QByteArray name = QSslCertificatePrivate::asn1ObjectName(obj); | - | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | result.d->oid = QString::fromUtf8(oid); | - | ||||||||||||||||||||||||
| 396 | result.d->name = QString::fromUtf8(name); | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | bool critical = q_X509_EXTENSION_get_critical(ext); | - | ||||||||||||||||||||||||
| 399 | result.d->critical = critical; | - | ||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | QVariant extensionValue = x509ExtensionToValue(ext); | - | ||||||||||||||||||||||||
| 403 | if (extensionValue.isValid()
| 8-10 | ||||||||||||||||||||||||
| 404 | result.d->value = extensionValue; | - | ||||||||||||||||||||||||
| 405 | result.d->supported = true; | - | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | return executed 8 times by 1 test: result;return result;Executed by:
executed 8 times by 1 test: return result;Executed by:
| 8 | ||||||||||||||||||||||||
| 408 | } | - | ||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | extensionValue = x509UnknownExtensionToValue(ext); | - | ||||||||||||||||||||||||
| 411 | if (extensionValue.isValid()
| 0-10 | ||||||||||||||||||||||||
| 412 | result.d->value = extensionValue; | - | ||||||||||||||||||||||||
| 413 | result.d->supported = false; | - | ||||||||||||||||||||||||
| 414 | return executed 10 times by 1 test: result;return result;Executed by:
executed 10 times by 1 test: return result;Executed by:
| 10 | ||||||||||||||||||||||||
| 415 | } | - | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 418 | } | - | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | QList<QSslCertificateExtension> QSslCertificate::extensions() const | - | ||||||||||||||||||||||||
| 421 | { | - | ||||||||||||||||||||||||
| 422 | QList<QSslCertificateExtension> result; | - | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | if (!d->x509
| 0-4 | ||||||||||||||||||||||||
| 425 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | int count = q_X509_get_ext_count(d->x509); | - | ||||||||||||||||||||||||
| 428 | result.reserve(count); | - | ||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||
| 430 | for (int i = 0; i < count
| 4-18 | ||||||||||||||||||||||||
| 431 | X509_EXTENSION *ext = q_X509_get_ext(d->x509, i); | - | ||||||||||||||||||||||||
| 432 | result << QSslCertificatePrivate::convertExtension(ext); | - | ||||||||||||||||||||||||
| 433 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | return executed 4 times by 1 test: result;return result;Executed by:
executed 4 times by 1 test: return result;Executed by:
| 4 | ||||||||||||||||||||||||
| 436 | } | - | ||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||
| 438 | QByteArray QSslCertificate::toPem() const | - | ||||||||||||||||||||||||
| 439 | { | - | ||||||||||||||||||||||||
| 440 | if (!d->x509
| 0-47 | ||||||||||||||||||||||||
| 441 | return never executed: QByteArray();return QByteArray();never executed: return QByteArray(); | 0 | ||||||||||||||||||||||||
| 442 | return executed 47 times by 1 test: d->QByteArray_from_X509(d->x509, QSsl::Pem);return d->QByteArray_from_X509(d->x509, QSsl::Pem);Executed by:
executed 47 times by 1 test: return d->QByteArray_from_X509(d->x509, QSsl::Pem);Executed by:
| 47 | ||||||||||||||||||||||||
| 443 | } | - | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | QByteArray QSslCertificate::toDer() const | - | ||||||||||||||||||||||||
| 446 | { | - | ||||||||||||||||||||||||
| 447 | if (!d->x509
| 1-89 | ||||||||||||||||||||||||
| 448 | return executed 1 time by 1 test: QByteArray();return QByteArray();Executed by:
executed 1 time by 1 test: return QByteArray();Executed by:
| 1 | ||||||||||||||||||||||||
| 449 | return executed 89 times by 1 test: d->QByteArray_from_X509(d->x509, QSsl::Der);return d->QByteArray_from_X509(d->x509, QSsl::Der);Executed by:
executed 89 times by 1 test: return d->QByteArray_from_X509(d->x509, QSsl::Der);Executed by:
| 89 | ||||||||||||||||||||||||
| 450 | } | - | ||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | QString QSslCertificate::toText() const | - | ||||||||||||||||||||||||
| 453 | { | - | ||||||||||||||||||||||||
| 454 | if (!d->x509
| 0-3 | ||||||||||||||||||||||||
| 455 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 456 | return executed 3 times by 1 test: d->text_from_X509(d->x509);return d->text_from_X509(d->x509);Executed by:
executed 3 times by 1 test: return d->text_from_X509(d->x509);Executed by:
| 3 | ||||||||||||||||||||||||
| 457 | } | - | ||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||
| 462 | void QSslCertificatePrivate::init(const QByteArray &data, QSsl::EncodingFormat format) | - | ||||||||||||||||||||||||
| 463 | { | - | ||||||||||||||||||||||||
| 464 | if (!data.isEmpty()
| 73-30192 | ||||||||||||||||||||||||
| 465 | const QList<QSslCertificate> certs = (
| 13-60 | ||||||||||||||||||||||||
| 466 | ? certificatesFromPem(data, 1) | - | ||||||||||||||||||||||||
| 467 | : certificatesFromDer(data, 1); | - | ||||||||||||||||||||||||
| 468 | if (!certs.isEmpty()
| 3-70 | ||||||||||||||||||||||||
| 469 | *this = *certs.first().d; | - | ||||||||||||||||||||||||
| 470 | if (x509
| 0-70 | ||||||||||||||||||||||||
| 471 | x509 = q_X509_dup(x509); executed 70 times by 3 tests: x509 = q_X509_dup(x509);Executed by:
| 70 | ||||||||||||||||||||||||
| 472 | } executed 70 times by 3 tests: end of blockExecuted by:
| 70 | ||||||||||||||||||||||||
| 473 | } executed 73 times by 3 tests: end of blockExecuted by:
| 73 | ||||||||||||||||||||||||
| 474 | } executed 30265 times by 16 tests: end of blockExecuted by:
| 30265 | ||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::EncodingFormat format) | - | ||||||||||||||||||||||||
| 478 | { | - | ||||||||||||||||||||||||
| 479 | if (!x509
| 0-136 | ||||||||||||||||||||||||
| 480 | for (bool qt_category_enabled = lcSsl().isWarningEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 525, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocketBackendPrivate::X509_to_QByteArray: null X509"); | 0 | ||||||||||||||||||||||||
| 481 | return never executed: QByteArray();return QByteArray();never executed: return QByteArray(); | 0 | ||||||||||||||||||||||||
| 482 | } | - | ||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | int length = q_i2d_X509(x509, 0); | - | ||||||||||||||||||||||||
| 486 | QByteArray array; | - | ||||||||||||||||||||||||
| 487 | array.resize(length); | - | ||||||||||||||||||||||||
| 488 | char *data = array.data(); | - | ||||||||||||||||||||||||
| 489 | char **dataP = &data; | - | ||||||||||||||||||||||||
| 490 | unsigned char **dataPu = (unsigned char **)dataP; | - | ||||||||||||||||||||||||
| 491 | if (q_i2d_X509(x509, dataPu) < 0
| 0-136 | ||||||||||||||||||||||||
| 492 | return never executed: QByteArray();return QByteArray();never executed: return QByteArray(); | 0 | ||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||
| 494 | if (format == QSsl::Der
| 47-89 | ||||||||||||||||||||||||
| 495 | return executed 89 times by 1 test: array;return array;Executed by:
executed 89 times by 1 test: return array;Executed by:
| 89 | ||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | array = array.toBase64(); | - | ||||||||||||||||||||||||
| 499 | QByteArray tmp; | - | ||||||||||||||||||||||||
| 500 | for (int i = 0; i <= array.size() - 64
| 47-518 | ||||||||||||||||||||||||
| 501 | tmp += QByteArray::fromRawData(array.data() + i, 64); | - | ||||||||||||||||||||||||
| 502 | tmp += '\n'; | - | ||||||||||||||||||||||||
| 503 | } executed 518 times by 1 test: end of blockExecuted by:
| 518 | ||||||||||||||||||||||||
| 504 | if (int remainder = array.size() % 64
| 1-46 | ||||||||||||||||||||||||
| 505 | tmp += QByteArray::fromRawData(array.data() + array.size() - remainder, remainder); | - | ||||||||||||||||||||||||
| 506 | tmp += '\n'; | - | ||||||||||||||||||||||||
| 507 | } executed 46 times by 1 test: end of blockExecuted by:
| 46 | ||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||
| 509 | return executed 47 times by 1 test: "-----BEGIN CERTIFICATE-----" "\n" + tmp + "-----END CERTIFICATE-----" "\n";return "-----BEGIN CERTIFICATE-----" "\n" + tmp + "-----END CERTIFICATE-----" "\n";Executed by:
executed 47 times by 1 test: return "-----BEGIN CERTIFICATE-----" "\n" + tmp + "-----END CERTIFICATE-----" "\n";Executed by:
| 47 | ||||||||||||||||||||||||
| 510 | } | - | ||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||
| 512 | QString QSslCertificatePrivate::text_from_X509(X509 *x509) | - | ||||||||||||||||||||||||
| 513 | { | - | ||||||||||||||||||||||||
| 514 | if (!x509
| 0-3 | ||||||||||||||||||||||||
| 515 | for (bool qt_category_enabled = lcSsl().isWarningEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 560, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocketBackendPrivate::text_from_X509: null X509"); | 0 | ||||||||||||||||||||||||
| 516 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 517 | } | - | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | QByteArray result; | - | ||||||||||||||||||||||||
| 520 | BIO *bio = q_BIO_new(q_BIO_s_mem()); | - | ||||||||||||||||||||||||
| 521 | if (!bio
| 0-3 | ||||||||||||||||||||||||
| 522 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | q_X509_print(bio, x509); | - | ||||||||||||||||||||||||
| 525 | - | |||||||||||||||||||||||||
| 526 | QVarLengthArray<char, 16384> data; | - | ||||||||||||||||||||||||
| 527 | int count = q_BIO_read(bio, data.data(), 16384); | - | ||||||||||||||||||||||||
| 528 | if ( count > 0
| 0-3 | ||||||||||||||||||||||||
| 529 | result = QByteArray( data.data(), count ); | - | ||||||||||||||||||||||||
| 530 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||
| 532 | q_BIO_free(bio); | - | ||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||
| 534 | return executed 3 times by 1 test: QString::fromLatin1(result);return QString::fromLatin1(result);Executed by:
executed 3 times by 1 test: return QString::fromLatin1(result);Executed by:
| 3 | ||||||||||||||||||||||||
| 535 | } | - | ||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | QByteArray QSslCertificatePrivate::asn1ObjectId(ASN1_OBJECT *object) | - | ||||||||||||||||||||||||
| 538 | { | - | ||||||||||||||||||||||||
| 539 | char buf[80]; | - | ||||||||||||||||||||||||
| 540 | q_OBJ_obj2txt(buf, sizeof(buf), object, 1); | - | ||||||||||||||||||||||||
| 541 | - | |||||||||||||||||||||||||
| 542 | return executed 20 times by 1 test: QByteArray(buf);return QByteArray(buf);Executed by:
executed 20 times by 1 test: return QByteArray(buf);Executed by:
| 20 | ||||||||||||||||||||||||
| 543 | } | - | ||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||
| 546 | QByteArray QSslCertificatePrivate::asn1ObjectName(ASN1_OBJECT *object) | - | ||||||||||||||||||||||||
| 547 | { | - | ||||||||||||||||||||||||
| 548 | int nid = q_OBJ_obj2nid(object); | - | ||||||||||||||||||||||||
| 549 | if (nid != 0
| 2-2739 | ||||||||||||||||||||||||
| 550 | return executed 2739 times by 8 tests: QByteArray(q_OBJ_nid2sn(nid));return QByteArray(q_OBJ_nid2sn(nid));Executed by:
executed 2739 times by 8 tests: return QByteArray(q_OBJ_nid2sn(nid));Executed by:
| 2739 | ||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||
| 552 | return executed 2 times by 1 test: asn1ObjectId(object);return asn1ObjectId(object);Executed by:
executed 2 times by 1 test: return asn1ObjectId(object);Executed by:
| 2 | ||||||||||||||||||||||||
| 553 | } | - | ||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | static QMap<QByteArray, QString> _q_mapFromX509Name(X509_NAME *name) | - | ||||||||||||||||||||||||
| 556 | { | - | ||||||||||||||||||||||||
| 557 | QMap<QByteArray, QString> info; | - | ||||||||||||||||||||||||
| 558 | for (int i = 0; i < q_X509_NAME_entry_count(name)
| 432-2719 | ||||||||||||||||||||||||
| 559 | X509_NAME_ENTRY *e = q_X509_NAME_get_entry(name, i); | - | ||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||
| 561 | QByteArray name = QSslCertificatePrivate::asn1ObjectName(q_X509_NAME_ENTRY_get_object(e)); | - | ||||||||||||||||||||||||
| 562 | unsigned char *data = 0; | - | ||||||||||||||||||||||||
| 563 | int size = q_ASN1_STRING_to_UTF8(&data, q_X509_NAME_ENTRY_get_data(e)); | - | ||||||||||||||||||||||||
| 564 | info.insertMulti(name, QString::fromUtf8((char*)data, size)); | - | ||||||||||||||||||||||||
| 565 | q_CRYPTO_free(data); | - | ||||||||||||||||||||||||
| 566 | } executed 2719 times by 8 tests: end of blockExecuted by:
| 2719 | ||||||||||||||||||||||||
| 567 | - | |||||||||||||||||||||||||
| 568 | return executed 432 times by 8 tests: info;return info;Executed by:
executed 432 times by 8 tests: return info;Executed by:
| 432 | ||||||||||||||||||||||||
| 569 | } | - | ||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||
| 571 | QSslCertificate QSslCertificatePrivate::QSslCertificate_from_X509(X509 *x509) | - | ||||||||||||||||||||||||
| 572 | { | - | ||||||||||||||||||||||||
| 573 | QSslCertificate certificate; | - | ||||||||||||||||||||||||
| 574 | if (!x509
| 0-20227 | ||||||||||||||||||||||||
| 575 | return executed 44 times by 2 tests: certificate;return certificate;Executed by:
executed 44 times by 2 tests: return certificate;Executed by:
| 44 | ||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | ASN1_TIME *nbef = ((x509)->cert_info->validity->notBefore); | - | ||||||||||||||||||||||||
| 578 | ASN1_TIME *naft = ((x509)->cert_info->validity->notAfter); | - | ||||||||||||||||||||||||
| 579 | certificate.d->notValidBefore = q_getTimeFromASN1(nbef); | - | ||||||||||||||||||||||||
| 580 | certificate.d->notValidAfter = q_getTimeFromASN1(naft); | - | ||||||||||||||||||||||||
| 581 | certificate.d->null = false; | - | ||||||||||||||||||||||||
| 582 | certificate.d->x509 = q_X509_dup(x509); | - | ||||||||||||||||||||||||
| 583 | - | |||||||||||||||||||||||||
| 584 | return executed 20227 times by 8 tests: certificate;return certificate;Executed by:
executed 20227 times by 8 tests: return certificate;Executed by:
| 20227 | ||||||||||||||||||||||||
| 585 | } | - | ||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | static bool matchLineFeed(const QByteArray &pem, int *offset) | - | ||||||||||||||||||||||||
| 588 | { | - | ||||||||||||||||||||||||
| 589 | char ch = 0; | - | ||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||
| 592 | while (*
| 1-38312 | ||||||||||||||||||||||||
| 593 | ++* executed 4 times by 1 test: offset;++*offset;Executed by:
executed 4 times by 1 test: ++*offset;Executed by:
| 4 | ||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||
| 595 | if (ch == '\n'
| 1-38308 | ||||||||||||||||||||||||
| 596 | *offset += 1; | - | ||||||||||||||||||||||||
| 597 | return executed 38308 times by 4 tests: true;return true;Executed by:
executed 38308 times by 4 tests: return true;Executed by:
| 38308 | ||||||||||||||||||||||||
| 598 | } | - | ||||||||||||||||||||||||
| 599 | if (ch == '\r'
| 0-1 | ||||||||||||||||||||||||
| 600 | *offset += 2; | - | ||||||||||||||||||||||||
| 601 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 602 | } | - | ||||||||||||||||||||||||
| 603 | return executed 1 time by 1 test: false;return false;Executed by:
executed 1 time by 1 test: return false;Executed by:
| 1 | ||||||||||||||||||||||||
| 604 | } | - | ||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||
| 606 | QList<QSslCertificate> QSslCertificatePrivate::certificatesFromPem(const QByteArray &pem, int count) | - | ||||||||||||||||||||||||
| 607 | { | - | ||||||||||||||||||||||||
| 608 | QList<QSslCertificate> certificates; | - | ||||||||||||||||||||||||
| 609 | QSslSocketPrivate::ensureInitialized(); | - | ||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||
| 611 | int offset = 0; | - | ||||||||||||||||||||||||
| 612 | while (count == -1
| 58-28897 | ||||||||||||||||||||||||
| 613 | int startPos = pem.indexOf("-----BEGIN CERTIFICATE-----", offset); | - | ||||||||||||||||||||||||
| 614 | if (startPos == -1
| 9801-19156 | ||||||||||||||||||||||||
| 615 | break; executed 9801 times by 4 tests: break;Executed by:
| 9801 | ||||||||||||||||||||||||
| 616 | startPos += sizeof("-----BEGIN CERTIFICATE-----") - 1; | - | ||||||||||||||||||||||||
| 617 | if (!matchLineFeed(pem, &startPos)
| 1-19155 | ||||||||||||||||||||||||
| 618 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | int endPos = pem.indexOf("-----END CERTIFICATE-----", startPos); | - | ||||||||||||||||||||||||
| 621 | if (endPos == -1
| 1-19154 | ||||||||||||||||||||||||
| 622 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||
| 624 | offset = endPos + sizeof("-----END CERTIFICATE-----") - 1; | - | ||||||||||||||||||||||||
| 625 | if (offset < pem.size()
| 0-19153 | ||||||||||||||||||||||||
| 626 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 627 | - | |||||||||||||||||||||||||
| 628 | QByteArray decoded = QByteArray::fromBase64( | - | ||||||||||||||||||||||||
| 629 | QByteArray::fromRawData(pem.data() + startPos, endPos - startPos)); | - | ||||||||||||||||||||||||
| 630 | const unsigned char *data = (const unsigned char *)decoded.data(); | - | ||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||
| 632 | if (X509 *x509 = q_d2i_X509(0, &data, decoded.size())
| 0-19154 | ||||||||||||||||||||||||
| 633 | certificates << QSslCertificate_from_X509(x509); | - | ||||||||||||||||||||||||
| 634 | q_X509_free(x509); | - | ||||||||||||||||||||||||
| 635 | } executed 19154 times by 4 tests: end of blockExecuted by:
| 19154 | ||||||||||||||||||||||||
| 636 | } executed 19154 times by 4 tests: end of blockExecuted by:
| 19154 | ||||||||||||||||||||||||
| 637 | - | |||||||||||||||||||||||||
| 638 | return executed 9861 times by 4 tests: certificates;return certificates;Executed by:
executed 9861 times by 4 tests: return certificates;Executed by:
| 9861 | ||||||||||||||||||||||||
| 639 | } | - | ||||||||||||||||||||||||
| 640 | - | |||||||||||||||||||||||||
| 641 | QList<QSslCertificate> QSslCertificatePrivate::certificatesFromDer(const QByteArray &der, int count) | - | ||||||||||||||||||||||||
| 642 | { | - | ||||||||||||||||||||||||
| 643 | QList<QSslCertificate> certificates; | - | ||||||||||||||||||||||||
| 644 | QSslSocketPrivate::ensureInitialized(); | - | ||||||||||||||||||||||||
| 645 | - | |||||||||||||||||||||||||
| 646 | const unsigned char *data = (const unsigned char *)der.data(); | - | ||||||||||||||||||||||||
| 647 | int size = der.size(); | - | ||||||||||||||||||||||||
| 648 | - | |||||||||||||||||||||||||
| 649 | while (size > 0
| 0-57 | ||||||||||||||||||||||||
| 650 | if (X509 *x509 = q_d2i_X509(0, &data, size)
| 14-43 | ||||||||||||||||||||||||
| 651 | certificates << QSslCertificate_from_X509(x509); | - | ||||||||||||||||||||||||
| 652 | q_X509_free(x509); | - | ||||||||||||||||||||||||
| 653 | } executed 14 times by 1 test: else {end of blockExecuted by:
| 14 | ||||||||||||||||||||||||
| 654 | break; executed 43 times by 1 test: break;Executed by:
| 43 | ||||||||||||||||||||||||
| 655 | } | - | ||||||||||||||||||||||||
| 656 | size -= ((const char *)data - der.data()); | - | ||||||||||||||||||||||||
| 657 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | return executed 57 times by 1 test: certificates;return certificates;Executed by:
executed 57 times by 1 test: return certificates;Executed by:
| 57 | ||||||||||||||||||||||||
| 660 | } | - | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |