diff options
-rw-r--r-- | src/network/ssl/qsslcertificate.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index c128da9..3793b1e 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -252,19 +252,19 @@ QByteArray QSslCertificate::version() const { if (d->versionString.isEmpty() && d->x509) d->versionString = - QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version))); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1); return d->versionString; } /*! - Returns the certificate's serial number string. + Returns the certificate's serial number string in decimal format. */ QByteArray QSslCertificate::serialNumber() const { if (d->serialNumberString.isEmpty() && d->x509) d->serialNumberString = - QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber)) + 1); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber))); return d->serialNumberString; } diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index add48c4..4dfb6b9 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -267,6 +267,8 @@ void tst_QSslCertificate::compareCertificates( QCOMPARE(cert1.alternateSubjectNames(), cert2.alternateSubjectNames()); QCOMPARE(cert1.effectiveDate(), cert2.effectiveDate()); QCOMPARE(cert1.expiryDate(), cert2.expiryDate()); + QCOMPARE(cert1.version(), cert2.version()); + QCOMPARE(cert1.serialNumber(), cert2.serialNumber()); // ### add more functions here ... } @@ -677,7 +679,9 @@ void tst_QSslCertificate::certInfo() QCOMPARE(cert.subjectInfo("C"), QString("NO")); QCOMPARE(cert.subjectInfo("ST"), QString()); - QCOMPARE(cert.version(), QByteArray()); + QCOMPARE(cert.version(), QByteArray::number(1)); + QCOMPARE(cert.serialNumber(), QByteArray::number(17)); + QCOMPARE(cert.toPem().constData(), (const char*)pem); QCOMPARE(cert.toDer(), QByteArray::fromHex(der)); |