Example #1
0
JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zsock__1_1setCurveSecretkey (JNIEnv *env, jclass c, jlong self, jstring curve_secretkey)
{
    char *curve_secretkey_ = (char *) (*env)->GetStringUTFChars (env, curve_secretkey, NULL);
    zsock_set_curve_secretkey ((zsock_t *) (intptr_t) self, curve_secretkey_);
    (*env)->ReleaseStringUTFChars (env, curve_secretkey, curve_secretkey_);
}
Example #2
0
static zsock_t *
s_self_create_socket (self_t *self, char *type_name, char *endpoints, proxy_socket selected_socket)
{
    //  This array matches ZMQ_XXX type definitions
    assert (ZMQ_PAIR == 0);
    char *type_names [] = {
        "PAIR", "PUB", "SUB", "REQ", "REP",
        "DEALER", "ROUTER", "PULL", "PUSH",
        "XPUB", "XSUB", type_name
    };
    //  We always match type at least at end of table
    int index;
    for (index = 0; strneq (type_name, type_names [index]); index++) ;
    if (index > ZMQ_XSUB) {
        zsys_error ("zproxy: invalid socket type '%s'", type_name);
        return NULL;
    }
    zsock_t *sock = zsock_new (index);
    if (sock) {
#if (ZMQ_VERSION_MAJOR == 4)
        if (self->domain [selected_socket]) {
            // Apply authentication domain
            zsock_set_zap_domain (sock, self->domain [selected_socket]);
        }
        if (self->auth_type [selected_socket] == AUTH_PLAIN) {
            // Enable plain authentication
            zsock_set_plain_server (sock, 1);
        }
        else
        if (self->auth_type [selected_socket] == AUTH_CURVE) {
            // Apply certificate keys
            char *public_key = self->public_key [selected_socket];
            assert(public_key);
            char *secret_key = self->secret_key [selected_socket];
            assert(secret_key);
            zsock_set_curve_publickey (sock, public_key);
            zsock_set_curve_secretkey (sock, secret_key);

            // Enable curve authentication
            zsock_set_curve_server (sock, 1);
        }
#endif
        if (zsock_attach (sock, endpoints, true)) {
            zsys_error ("zproxy: invalid endpoints '%s'", endpoints);
            zsock_destroy (&sock);
        }
    }
    return sock;
}
Example #3
0
///
//  Set socket option `curve_secretkey`.
void QZsock::setCurveSecretkey (const QString &curveSecretkey)
{
    zsock_set_curve_secretkey (self, curveSecretkey.toUtf8().data());
    
}