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

Private to protected transition of getOpenSSLCtx method #1

Open
wants to merge 3 commits into
base: 3.9.x
Choose a base branch
from

Conversation

tsunday
Copy link

@tsunday tsunday commented Jul 13, 2016

Overview of the change

This small change allows to override default behaviour of OpenSSLContextSpi in derived classes. Base OpenSSLContexSpi was partially designed to allow overriding - see virtual methods like providerInit() or providerGetSocketFactory(). As for now ActiveMQ-Cpp doesn't support changing any of the cipher suites or protocol version used within OpenSSL secure connection. This fix allows users of the library to override default OpenSSLContextSpi with their own class. The main reason of changing the access level of getOpenSSLCtx method was the need of executing some of the openssl library functions on SSL_CTX object from derived class in overrided providerInit() method. Leaving this getter private prevents from changing any of the SSL_CTX parameters and makes derived classes useless.

Example usage

#include <openssl/ssl.h>

class MyOpenSSLContextSpi : public decaf::internal::net::ssl::openssl::OpenSSLContextSpi
{
    public:
        MyOpenSSLContextSpi();

        virtual void providerInit(decaf::security::SecureRandom* random);
};

void MyOpenSSLContextSpi::providerInit(decaf::security::SecureRandom* random)
{
    OpenSSLContextSpi::providerInit(random);

    SSL_CTX* ctx = static_cast<SSL_CTX*>(getOpenSSLCtx()); // private to protected conversion required
    SSL_CTX_set_cipher_list(ctx, "RC4-SHA");
}

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.

1 participant