From 80abd7051c08f69d1ad8d6abc01cf545ca2cca68 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Tue, 15 Oct 2019 17:23:12 +0900 Subject: [PATCH] Add tizen dlog for debugging Change-Id: I08b9067f7f9189f8a912467b7064d01f303dd0fa --- meson.build | 7 +++++++ meson_options.txt | 1 + packaging/glib-networking.spec | 8 +++++++- tls/gnutls/gtlsbackend-gnutls.c | 4 ---- tls/gnutls/gtlscertificate-gnutls.c | 4 ---- tls/gnutls/gtlsconnection-gnutls.c | 5 ----- tls/openssl/gtlscertificate-openssl.c | 2 +- tls/openssl/gtlsclientconnection-openssl.c | 10 ++++++++++ tls/openssl/gtlsconnection-openssl.c | 7 +++++++ tls/openssl/meson.build | 4 ++++ tls/openssl/openssl-include.h | 17 +++++++++++++++++ 11 files changed, 54 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index d3d5642..c5cab77 100644 --- a/meson.build +++ b/meson.build @@ -41,6 +41,12 @@ common_flags = [ '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46' ] +# TIZEN dlog +if get_option('tizen_debug') + debug_dep = dependency('dlog') + config_h.set('TIZEN_DEBUG', get_option('tizen_debug')) +endif + add_project_arguments(common_flags, language: 'c') symbol_map = join_paths(meson.current_source_dir(), meson.project_name() + '.map') @@ -206,4 +212,5 @@ output += ' libproxy support: ' + libproxy_dep.found().to_string() + '\n' output += ' GNOME proxy support: ' + gsettings_desktop_schemas_dep.found().to_string() + '\n' output += ' TIZEN default CA file: ' + get_option('default_ca_file') + '\n' output += ' TIZEN extension: ' + get_option('tizen_ext').to_string() + '\n' +output += ' TIZEN debug: ' + get_option('tizen_debug').to_string() + '\n' message(output) diff --git a/meson_options.txt b/meson_options.txt index cab6d48..7064861 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,3 +6,4 @@ option('installed_tests', type: 'boolean', value: false, description: 'enable in option('static_modules', type: 'boolean', value: false, description: 'build static modules') option('default_ca_file', type: 'string', value: '', description: 'set default CA file') option('tizen_ext', type: 'boolean', value: false, description: 'enable TIZEN extension') +option('tizen_debug', type: 'boolean', value: false, description: 'enable TIZEN debug') diff --git a/packaging/glib-networking.spec b/packaging/glib-networking.spec index 1c9ee9a..8ed408c 100755 --- a/packaging/glib-networking.spec +++ b/packaging/glib-networking.spec @@ -36,7 +36,13 @@ Currently, there is only a proxy module based on libproxy. cp %{SOURCE1001} . %build -meson --prefix /usr/ --libdir %{_libdir} build -Dstatic_modules=false -Dgnutls=disabled -Dopenssl=enabled -Ddefault_ca_file=%{TZ_SYS_RO_CA_BUNDLE} -Dtizen_ext=true +meson --prefix /usr/ --libdir %{_libdir} build \ + -Dstatic_modules=false \ + -Dgnutls=disabled \ + -Dopenssl=enabled \ + -Ddefault_ca_file=%{TZ_SYS_RO_CA_BUNDLE} \ + -Dtizen_ext=true \ + -Dtizen_debug=true ninja -C build all %install diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c index c22530e..d977e1b 100644 --- a/tls/gnutls/gtlsbackend-gnutls.c +++ b/tls/gnutls/gtlsbackend-gnutls.c @@ -56,11 +56,7 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (GTlsBackendGnutls, g_tls_backend_gnutls, G_TYPE_ static void gtls_log_func (int level, const char *msg) { -#if ENABLE(TIZEN_DLOG) - TIZEN_LOGI("GTLS: %s", msg); -#else g_print ("GTLS: %s", msg); -#endif } #endif diff --git a/tls/gnutls/gtlscertificate-gnutls.c b/tls/gnutls/gtlscertificate-gnutls.c index 62a774b..cc30936 100755 --- a/tls/gnutls/gtlscertificate-gnutls.c +++ b/tls/gnutls/gtlscertificate-gnutls.c @@ -644,10 +644,6 @@ g_tls_certificate_gnutls_verify_identity (GTlsCertificateGnutls *gnutls, /* FIXME: check sRVName and uniformResourceIdentifier * subjectAltNames, if appropriate for @identity. */ -#if ENABLE(TIZEN_DLOG) - TIZEN_LOGI("[Network] SSL HandShake - Bad Identity"); -#endif - return G_TLS_CERTIFICATE_BAD_IDENTITY; } diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c index 729c66c..1163fb5 100755 --- a/tls/gnutls/gtlsconnection-gnutls.c +++ b/tls/gnutls/gtlsconnection-gnutls.c @@ -1822,11 +1822,6 @@ verify_peer_certificate (GTlsConnectionGnutls *gnutls, database = g_tls_connection_get_database (conn); if (database == NULL) { - -#if ENABLE(TIZEN_DLOG) - TIZEN_LOGI("[Network] SSL HandShake - Unknown CA"); -#endif - errors |= G_TLS_CERTIFICATE_UNKNOWN_CA; errors |= g_tls_certificate_verify (peer_certificate, peer_identity, NULL); } diff --git a/tls/openssl/gtlscertificate-openssl.c b/tls/openssl/gtlscertificate-openssl.c index 3472cd9..4bd9f80 100644 --- a/tls/openssl/gtlscertificate-openssl.c +++ b/tls/openssl/gtlscertificate-openssl.c @@ -557,7 +557,7 @@ g_tls_certificate_openssl_verify_identity (GTlsCertificateOpenssl *openssl, /* FIXME: check sRVName and uniformResourceIdentifier * subjectAltNames, if appropriate for @identity. */ - + TIZEN_LOGE("SSL HandShake - Bad Identity"); return G_TLS_CERTIFICATE_BAD_IDENTITY; } diff --git a/tls/openssl/gtlsclientconnection-openssl.c b/tls/openssl/gtlsclientconnection-openssl.c index 70e26a0..3c189c1 100644 --- a/tls/openssl/gtlsclientconnection-openssl.c +++ b/tls/openssl/gtlsclientconnection-openssl.c @@ -341,6 +341,9 @@ retrieve_certificate (SSL *ssl, priv = g_tls_client_connection_openssl_get_instance_private (client); + TIZEN_LOGI("ssl[%p] client[%p] tls[%p] openssl[%p] priv[%p] data_index[%d]", + ssl, client, tls, openssl, priv, data_index); + tls->certificate_requested = TRUE; priv->ca_list = SSL_get_client_CA_list (priv->ssl); @@ -392,6 +395,9 @@ generate_session_id (SSL *ssl, client = SSL_get_ex_data (ssl, data_index); priv = g_tls_client_connection_openssl_get_instance_private (client); + TIZEN_LOGI("ssl[%p] client[%p] priv[%p] data_index[%d]", + ssl, client, priv, data_index); + len = MIN (*id_len, g_bytes_get_size (priv->session_id)); memcpy (id, g_bytes_get_data (priv->session_id, NULL), len); @@ -540,8 +546,12 @@ g_tls_client_connection_openssl_initable_init (GInitable *initable, if (data_index == -1) { data_index = SSL_get_ex_new_index (0, (void *)"gtlsclientconnection", NULL, NULL, NULL); + TIZEN_LOGI("new data_index[%d]", data_index); + } else { + TIZEN_LOGI("data_index[%d] is already exist", data_index); } SSL_set_ex_data (priv->ssl, data_index, client); + TIZEN_LOGI("[SSL] set extra data: priv->ssl[%p] data_index[%d] client[%p]", priv->ssl, data_index, client); #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME if (hostname) diff --git a/tls/openssl/gtlsconnection-openssl.c b/tls/openssl/gtlsconnection-openssl.c index c6df559..8252516 100644 --- a/tls/openssl/gtlsconnection-openssl.c +++ b/tls/openssl/gtlsconnection-openssl.c @@ -329,6 +329,7 @@ verify_peer_certificate (GTlsConnectionOpenssl *openssl, database = g_tls_connection_get_database (conn); if (database == NULL) { + TIZEN_LOGE("SSL HandShake - Unknown CA"); errors |= G_TLS_CERTIFICATE_UNKNOWN_CA; errors |= g_tls_certificate_verify (peer_certificate, peer_identity, NULL); } @@ -374,6 +375,8 @@ g_tls_connection_openssl_handshake (GTlsConnectionBase *tls, ssl = g_tls_connection_openssl_get_ssl (openssl); + TIZEN_LOGI("tls[%p] openssl[%p] priv[%p] ssl[%p]", tls, openssl, priv, ssl); + BEGIN_OPENSSL_IO (openssl, G_IO_IN | G_IO_OUT, TRUE, cancellable); ret = SSL_do_handshake (ssl); END_OPENSSL_IO (openssl, G_IO_IN | G_IO_OUT, ret, status, @@ -406,6 +409,8 @@ g_tls_connection_openssl_complete_handshake (GTlsConnectionBase *tls, priv = g_tls_connection_openssl_get_instance_private (openssl); + TIZEN_LOGI("tls[%p] openssl[%p] priv[%p]", tls, openssl, priv); + peer_certificate = priv->peer_certificate_tmp; priv->peer_certificate_tmp = NULL; peer_certificate_errors = priv->peer_certificate_errors_tmp; @@ -548,6 +553,8 @@ g_tls_connection_openssl_close (GTlsConnectionBase *tls, ssl = g_tls_connection_openssl_get_ssl (openssl); priv = g_tls_connection_openssl_get_instance_private (openssl); + TIZEN_LOGI("tls[%p] openssl[%p] priv[%p] ssl[%p]", tls, openssl, priv, ssl); + priv->shutting_down = TRUE; BEGIN_OPENSSL_IO (openssl, G_IO_IN | G_IO_OUT, TRUE, cancellable); diff --git a/tls/openssl/meson.build b/tls/openssl/meson.build index 529b44b..6255f97 100644 --- a/tls/openssl/meson.build +++ b/tls/openssl/meson.build @@ -22,6 +22,10 @@ deps = [ openssl_dep, ] +if get_option('tizen_debug') + deps += [debug_dep] +endif + module = shared_module( 'gioopenssl', sources: sources, diff --git a/tls/openssl/openssl-include.h b/tls/openssl/openssl-include.h index 7a6a460..38729f8 100644 --- a/tls/openssl/openssl-include.h +++ b/tls/openssl/openssl-include.h @@ -33,6 +33,23 @@ #include "glib.h" +#ifdef TIZEN_DEBUG +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "glib-networking" +#define TIZEN_LOGD(foramt, args...) LOGD(format, ##args) +#define TIZEN_LOGI(format, args...) LOGI(format, ##args) +#define TIZEN_LOGE(format, args...) LOGE(format, ##args) +#else +#define TIZEN_LOGD(foramt, args...) +#define TIZEN_LOGI(format, args...) +#define TIZEN_LOGE(format, args...) +#endif + #ifdef G_OS_WIN32 #define WIN32_LEAN_AND_MEAN #include -- 2.7.4