Changeset 561 for trunk/src/network/ssl/qsslcertificate.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/network/ssl/qsslcertificate.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 47 47 48 48 \reentrant 49 \ingroup io49 \ingroup network 50 50 \ingroup ssl 51 51 \inmodule QtNetwork … … 72 72 certificate, its subject, and its issuer, by calling one of the 73 73 many accessor functions, including version(), serialNumber(), 74 issuerInfo() and subjectInfo(). You can call notValidBefore() and 75 notValidAfter() to check when the certificate was issued, and when 76 it expires. The publicKey() function returns the certificate 74 issuerInfo() and subjectInfo(). You can call effectiveDate() and 75 expiryDate() to check when the certificate starts being 76 effective and when it expires. 77 The publicKey() function returns the certificate 77 78 subject's public key as a QSslKey. You can call issuerInfo() or 78 79 subjectInfo() to get detailed information about the certificate … … 126 127 QT_BEGIN_NAMESPACE 127 128 129 // forward declaration 130 static QMap<QString, QString> _q_mapFromOnelineName(char *name); 131 128 132 /*! 129 133 Constructs a QSslCertificate by reading \a format encoded data … … 158 162 QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d) 159 163 { 160 d->ref.ref();161 164 } 162 165 … … 166 169 QSslCertificate::~QSslCertificate() 167 170 { 168 if (!d->ref.deref())169 delete d;170 171 } 171 172 … … 176 177 QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other) 177 178 { 178 qAtomicAssign(d, other.d);179 d = other.d; 179 180 return *this; 180 181 } … … 242 243 if (isNull()) 243 244 return; 244 if (d->ref == 1)245 delete d;246 else247 d->ref.deref();248 249 245 d = new QSslCertificatePrivate; 250 246 } … … 255 251 QByteArray QSslCertificate::version() const 256 252 { 253 if (d->versionString.isEmpty() && d->x509) 254 d->versionString = 255 QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1); 256 257 257 return d->versionString; 258 258 } 259 259 260 260 /*! 261 Returns the certificate's serial number string .261 Returns the certificate's serial number string in decimal format. 262 262 */ 263 263 QByteArray QSslCertificate::serialNumber() const 264 264 { 265 if (d->serialNumberString.isEmpty() && d->x509) 266 d->serialNumberString = 267 QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber))); 268 265 269 return d->serialNumberString; 266 270 } … … 268 272 /*! 269 273 Returns a cryptographic digest of this certificate. By default, 270 an dMD5 digest will be generated, but you can also specify a274 an MD5 digest will be generated, but you can also specify a 271 275 custom \a algorithm. 272 276 */ … … 301 305 QString QSslCertificate::issuerInfo(SubjectInfo info) const 302 306 { 307 if (d->issuerInfo.isEmpty() && d->x509) 308 d->issuerInfo = 309 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(d->x509), 0, 0)); 310 303 311 return d->issuerInfo.value(_q_SubjectInfoToString(info)); 304 312 } … … 328 336 QString QSslCertificate::subjectInfo(SubjectInfo info) const 329 337 { 338 if (d->subjectInfo.isEmpty() && d->x509) 339 d->subjectInfo = 340 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(d->x509), 0, 0)); 341 330 342 return d->subjectInfo.value(_q_SubjectInfoToString(info)); 331 343 } … … 363 375 return result; 364 376 365 STACK *altNames = (STACK*)q_X509_get_ext_d2i(d->x509, NID_subject_alt_name, 0, 0);377 STACK_OF(GENERAL_NAME) *altNames = (STACK_OF(GENERAL_NAME)*)q_X509_get_ext_d2i(d->x509, NID_subject_alt_name, 0, 0); 366 378 367 379 if (altNames) { … … 378 390 379 391 const char *altNameStr = reinterpret_cast<const char *>(q_ASN1_STRING_data(genName->d.ia5)); 380 const QString altName = Q Latin1String(QByteArray(altNameStr, len));392 const QString altName = QString::fromLatin1(altNameStr, len); 381 393 if (genName->type == GEN_DNS) 382 394 result.insert(QSsl::DnsEntry, altName); … … 384 396 result.insert(QSsl::EmailEntry, altName); 385 397 } 386 q_sk_ free(altNames);398 q_sk_pop_free((STACK*)altNames, reinterpret_cast<void(*)(void*)>(q_sk_free)); 387 399 } 388 400 … … 611 623 array = array.toBase64(); 612 624 QByteArray tmp; 613 for (int i = 0; i < array.size() - 64; i += 64) {625 for (int i = 0; i <= array.size() - 64; i += 64) { 614 626 tmp += QByteArray::fromRawData(array.data() + i, 64); 615 627 tmp += "\n"; … … 662 674 if (!x509 || !QSslSocket::supportsSsl()) 663 675 return certificate; 664 665 certificate.d->issuerInfo =666 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(x509), 0, 0));667 certificate.d->subjectInfo =668 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(x509), 0, 0));669 676 670 677 ASN1_TIME *nbef = q_X509_get_notBefore(x509); … … 687 694 688 695 if (ch == '\n') { 689 *offset ++;696 *offset += 1; 690 697 return true; 691 698 } … … 767 774 debug << "QSslCertificate(" 768 775 << certificate.version() 769 << ","<< certificate.serialNumber()770 << ","<< certificate.digest().toBase64()771 << ","<< certificate.issuerInfo(QSslCertificate::Organization)772 << ","<< certificate.subjectInfo(QSslCertificate::Organization)773 << ","<< certificate.alternateSubjectNames()776 << ',' << certificate.serialNumber() 777 << ',' << certificate.digest().toBase64() 778 << ',' << certificate.issuerInfo(QSslCertificate::Organization) 779 << ',' << certificate.subjectInfo(QSslCertificate::Organization) 780 << ',' << certificate.alternateSubjectNames() 774 781 #ifndef QT_NO_TEXTSTREAM 775 << ","<< certificate.effectiveDate()776 << ","<< certificate.expiryDate()782 << ',' << certificate.effectiveDate() 783 << ',' << certificate.expiryDate() 777 784 #endif 778 << ")";785 << ')'; 779 786 return debug; 780 787 }
Note:
See TracChangeset
for help on using the changeset viewer.