Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use QSslConfiguration to setup an ssl connection #90

Merged
merged 2 commits into from
Feb 20, 2017

Conversation

ejvr
Copy link
Contributor

@ejvr ejvr commented Feb 19, 2017

2 changes:

  • Added an extra constructor to QMQTT::Client which allows a QSslConfiguration to be used when setting up an ssl connection, allowing users to change ssl options, add ca-certificates, etc... The original constructor to set up an ssl connection is still present, but I would not recommend using it, because some unexpected stuff happens, like loading certificates from the current working directory.
  • If the ignoreSelfSigned flag is set, only ssl errors related to self signed certificates will be ignored. In the current implementation all ssl errors will be ignored, which is not what the user asked for, and may cause security issues.

This patch incorporates patch #88 from @wiebeytec. I had to move the code involved, so merging his patch later would be quite hard.

@mwallnoefer mwallnoefer merged commit b0eece3 into emqx:master Feb 20, 2017
@wiebeytec
Copy link

wiebeytec commented Feb 21, 2017

I think there is a bug? When I set ignoreSelfSigned to false, it still accepts the connection. I'm not quite sure what's going in (edit: I mean going on).

In this code:

void QMQTT::SslSocket::sslErrors(const QList<QSslError> &errors)
{
    if (!_ignoreSelfSigned)
        return;
    for (QSslError error: errors)
    {
        if (error.error() != QSslError::SelfSignedCertificate ||
            error.error() != QSslError::SelfSignedCertificateInChain)
        {
            return;
        }
    }
    _socket->ignoreSslErrors();
}

It should return out of the method right away.

BTW, shouldn't that be && instead of ||? This way, the if is always true.

@mwallnoefer
Copy link
Collaborator

Also according to me || should be substituted with &&: the first error from errors which is not SelfSignedCertificate and also not SelfSignedCertificateInChain means that something other (= more impacting, like an expired certificate) got wrong. In this case we should return and hence NOT call ignoreSslErrors().

@ejvr @wiebeytec True?

@ejvr
Copy link
Contributor Author

ejvr commented Feb 21, 2017 via email

@mwallnoefer
Copy link
Collaborator

@ejvr Would you like to provide a follow-up patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants