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

Support for Riak security #32

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Support for Riak security #32

wants to merge 11 commits into from

Conversation

tomhel
Copy link

@tomhel tomhel commented Aug 16, 2016

This patch adds support for Riak security/authentication using passwords or certificates. To support TLS connections WolfSSL is used. Building with TLS/security support is optional.

Besides Riak security this patch also does the following:

  • fix ints.h include problem on Linux.
  • set NOSIGPIPE on socket write.

Build example:

cmake -DBUILD_SHARED_LIBS=1 -DWITH_WOLFSSL=1 src/

To connect to Riak securely, do this:

  1. create riack security options
  2. initialize riack security options
  3. connect to Riak
  4. start TLS
  5. perform authentication

Code example, connect to Riak securely using username and password:

riack_init();
riack_security_options security;
riack_init_security_options(&security);
riack_client *client = riack_new_client(0);
riack_connect(client, "127.0.0.1", 8087, 0);

riack_start_tls(client, &security);
riack_string user;
riack_string pw;
user.value = "riakuser";
user.len = strlen(user.value);
pw.value = "pass";
pw.len = strlen(pw.value);
riack_auth(client, &user, &pw);

if (riack_ping(client) == RIACK_SUCCESS)
    printf("pong");
}

riack_free(client);
riack_cleanup();

More examples are available in README.md.

Security options are set on the riack_security_options struct (in riack_defines.h):

/* Riack security options */
typedef struct _riack_security_options {
    /* Limit available ciphers, colon delimited list */
    char* ciphers;
    /* Load from file, PEM format */
    char* ca_file;
    char* cert_file;
    char* key_file;
    /* Load from memory, PEM format */
    unsigned char* ca_buffer;
    unsigned char* cert_buffer;
    unsigned char* key_buffer;
    /* Size of memory buffers */
    size_t ca_size;
    size_t cert_size;
    size_t key_size;
    /* SSL/TLS session timeout in seconds */
    unsigned int session_timeout;
} riack_security_options;

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