Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions core/merginapi.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can also connect to the same signal on the level of QNetworkAccessManager, see here. It would be better to attach to it in the constructor of MerginApi and listen to every request not just pingMergin.

Also logging the error description and which reply it is attached to seems enough to me, no need to dump the whole cert info.

Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,27 @@ void MerginApi::pingMergin()
request.setUrl( url );

QNetworkReply *reply = mManager->get( request );
#ifndef QT_NO_SSL
connect( reply, &QNetworkReply::sslErrors, this, [url]( const QList<QSslError> &errors )
{
CoreUtils::log( "URL attempting to access:", url.toString() );
for ( const auto &error : errors )
{
CoreUtils::log( "Error Description:", error.errorString() );
// Get the certificate causing the error
QSslCertificate cert = error.certificate();
if ( !cert.isNull() )
{
CoreUtils::log( "Subject (Common Name):", cert.subjectInfo( QSslCertificate::CommonName ).join( "," ) );
CoreUtils::log( "Issuer (Common Name):", cert.issuerInfo( QSslCertificate::CommonName ).join( "," ) );
CoreUtils::log( "Organization:", cert.subjectInfo( QSslCertificate::Organization ).join( "," ) );
CoreUtils::log( "Valid From:", cert.effectiveDate().toString() );
CoreUtils::log( "Expires On:", cert.expiryDate().toString() );
CoreUtils::log( "Fingerprint (SHA256):", cert.digest( QCryptographicHash::Sha256 ).toHex() );
}
}
} );
#endif
CoreUtils::log( "ping", QStringLiteral( "Requesting: " ) + url.toString() );
connect( reply, &QNetworkReply::finished, this, &MerginApi::pingMerginReplyFinished );
}
Expand Down
Loading