[ 
https://issues.apache.org/jira/browse/THRIFT-3369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15191985#comment-15191985
 ] 

ASF GitHub Bot commented on THRIFT-3369:
----------------------------------------

Github user nsuke commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/930#discussion_r55929143
  
    --- Diff: lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c ---
    @@ -0,0 +1,700 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +#include <errno.h>
    +#include <netdb.h>
    +#include <stdlib.h>
    +#include <string.h>
    +#include <unistd.h>
    +#include <sys/socket.h>
    +#include <netinet/in.h>
    +#include <openssl/ssl.h>
    +
    +#include <thrift/c_glib/thrift.h>
    +#include <thrift/c_glib/transport/thrift_transport.h>
    +#include <thrift/c_glib/transport/thrift_socket.h>
    +#include <thrift/c_glib/transport/thrift_ssl_socket.h>
    +
    +#define OPENSSL_VERSION_NO_THREAD_ID 0x10000000L
    +
    +
    +/* object properties */
    +enum _ThriftSSLSocketProperties
    +{
    +   PROP_THRIFT_SSL_SOCKET_CONTEXT = 3
    +};
    +
    +/* for errors coming from socket() and connect() */
    +// extern int errno;
    +
    +// To hold a global state management of openssl for all instances
    +static gboolean thrift_ssl_socket_openssl_initialized=FALSE;
    +static SSL_CTX* thrift_ssl_socket_global_context=NULL; // Should this be 
keept at class level?
    +
    +#if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_NO_THREAD_ID)
    +static unsigned long callbackThreadID() {
    +   return (unsigned long)pthread_self();
    +}
    +#endif
    +
    +
    +static void thrift_ssl_socket_static_locking_callback(int mode, int n, 
const char* unk, int id) {
    +   if (mode & CRYPTO_LOCK) {
    +           //              g_printf("We should lock thread %d\n", n);
    +           //mutexes[n].lock();
    +   } else {
    +           //              g_printf("We should unlock thread %d\n", n);
    +           //mutexes[n].unlock();
    +   }
    +}
    +
    +static void* thrift_ssl_socket_dyn_lock_create_callback(const char* unk, 
int id) {
    +   g_print("We should create a lock\n");
    +   return NULL;
    --- End diff --
    
    AFAIK, dynamic locking is optional. If we're not doing it, maybe we 
shouldn't register callbacks at all.
    We need static locking above before merging, though.


> Implement SSL/TLS support on C with c_glib
> ------------------------------------------
>
>                 Key: THRIFT-3369
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3369
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C glib - Library
>    Affects Versions: 0.9.1, 0.9.2, 0.9.3, 1.0
>            Reporter: Gonzalo Aguilar
>              Labels: features, patch
>             Fix For: 0.10.0, 1.0
>
>
> Implement SSL/TLS based on plain openssl instead of going through the way 
> defined in THRIFT-1016. 
> This help us to maintain a reference implementation and later switch over GIO 
> or whatever is defined. But also does not add any other dependencies to the 
> project. So bare minimum installation for supporting SSL/TLS is there and 
> aligned with CPP counterpart. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to