From f458ae7481ecb7ada63ed1eaaa8300e714465161 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Mon, 3 Apr 2017 11:35:03 +0900 Subject: [PATCH] Add new config option for GNUTLS log function Change-Id: I2c245836981f1655f1f376656a74754999aed9cb --- configure.ac | 22 ++++++++++++++++++++-- packaging/glib-networking.spec | 9 ++++++--- tls/gnutls/TIZEN.h | 6 +++++- tls/gnutls/gtlsbackend-gnutls.c | 6 ++++++ tls/gnutls/gtlscertificate-gnutls.c | 24 ++++++++++++------------ tls/gnutls/gtlsconnection-gnutls.c | 2 +- tls/gnutls/gtlsdatabase-gnutls.c | 6 +++--- 7 files changed, 53 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index f67f97a..72f4f81 100755 --- a/configure.ac +++ b/configure.ac @@ -183,11 +183,29 @@ AC_ARG_ENABLE(tizen-dlog, AC_MSG_CHECKING([for Tizen dlog]) if test $enable_tizen_dlog != no;then - AC_DEFINE(ENABLE_TIZEN_TV_DLOG, 1, [Add new feature, support to add tizen dlog in glib-networking]) + AC_DEFINE(ENABLE_TIZEN_DLOG, 1, [Add new feature, support to add tizen dlog in glib-networking]) fi AC_MSG_RESULT($enable_tizen_dlog) -AM_CONDITIONAL(TIZEN_TV_DLOG, [test $enable_tizen_dlog = yes]) +AM_CONDITIONAL(TIZEN_DLOG, [test $enable_tizen_dlog = yes]) + +dnl **************************** +dnl *** GNUTLS debug support *** +dnl **************************** + +AC_ARG_ENABLE(tizen-gnutls-debug, + AS_HELP_STRING([--enable-tizen-gnutls-debug], [Enable Tizen GNUTLS debug support ]), , + enable_tizen_gnutls_debug=no) + +AC_MSG_CHECKING([for Tizen GNUTLS debug]) +if test $enable_tizen_gnutls_debug != no;then + AC_DEFINE(ENABLE_TIZEN_GNUTLS_DEBUG, 1, + [Add new feature, support to enable GNUTLS debug function in glib-networking]) +fi +AC_MSG_RESULT($enable_tizen_gnutls_debug) + +AM_CONDITIONAL(TIZEN_GNUTLS_DEBUG, [test $enable_tizen_gnutls_debug = yes]) + dnl ***************************************************** dnl *** Tizen update gnutls default priority support *** diff --git a/packaging/glib-networking.spec b/packaging/glib-networking.spec index d071c5f..25c0441 100755 --- a/packaging/glib-networking.spec +++ b/packaging/glib-networking.spec @@ -41,16 +41,19 @@ export CFLAGS='-Wformat-nonliteral' %if %{with libproxy} --with-libproxy \ %endif + --enable-tizen-dlog \ +%if 0 + --enable-tizen-gnutls-debug \ +%endif %if "%{TIZEN_PROFILE_TV}" == "1" --enable-tizen-multiple-certificate=yes \ --enable-tizen-tv-update-default-priority \ - --enable-tizen-dlog \ --enable-tizen-performance-test-log \ %endif %if "%{TIZEN_PROFILE_TV}" == "1" - --with-ca-certificates=%{TZ_SYS_RO_CA_CERTS} + --with-ca-certificates=%{TZ_SYS_RO_CA_CERTS} \ %else - --with-ca-certificates=%{TZ_SYS_RO_CA_BUNDLE} + --with-ca-certificates=%{TZ_SYS_RO_CA_BUNDLE} \ %endif %__make %{?_smp_mflags} V=1 diff --git a/tls/gnutls/TIZEN.h b/tls/gnutls/TIZEN.h index a158b6d..fdbe652 100755 --- a/tls/gnutls/TIZEN.h +++ b/tls/gnutls/TIZEN.h @@ -8,7 +8,7 @@ #define ENABLE_TIZEN_NPN 1 #define ENABLE_TIZEN_EXT 1 -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_DLOG) #ifndef LOG_TAG #define LOG_TAG "glib-networking" /* This LOG_TAG should be defined before including dlog.h. Because dlog.h is using it. */ @@ -24,4 +24,8 @@ #endif +#if ENABLE(TIZEN_GNUTLS_DEBUG) +#define GTLS_GNUTLS_DEBUG 1 +#endif + #endif diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c index 55ec1a5..c193c22 100644 --- a/tls/gnutls/gtlsbackend-gnutls.c +++ b/tls/gnutls/gtlsbackend-gnutls.c @@ -31,6 +31,8 @@ #include "gtlsfiledatabase-gnutls.h" #include "gtlsserverconnection-gnutls.h" +#include "TIZEN.h" + struct _GTlsBackendGnutlsPrivate { GMutex mutex; @@ -47,7 +49,11 @@ 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 e47dcdd..29ae9fb 100755 --- a/tls/gnutls/gtlscertificate-gnutls.c +++ b/tls/gnutls/gtlscertificate-gnutls.c @@ -324,7 +324,7 @@ g_tls_certificate_gnutls_verify (GTlsCertificate *cert, gnutls_x509_crt_t *chain; GTlsCertificateFlags gtls_flags; time_t t, now; -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_TV_ADJUST_TIME) && ENABLE(TIZEN_DLOG) char timebuf[256]; #endif @@ -371,15 +371,15 @@ g_tls_certificate_gnutls_verify (GTlsCertificate *cert, { t = gnutls_x509_crt_get_activation_time (chain[i]); -#if ENABLE(TIZEN_TV_DLOG) - ctime_r(&now, timebuf); - TIZEN_LOGI("[Certificate] TV borad time is: %s", timebuf); - if (t != (time_t) -1) { - ctime_r(&t, timebuf); - TIZEN_LOGI("[Certificate] CA activation time is: %s", timebuf); - } - else - TIZEN_LOGI("[Certificate] gnutls_x509_crt_get_activation_time ERROR"); +#if ENABLE(TIZEN_TV_ADJUST_TIME) && ENABLE(TIZEN_DLOG) + ctime_r(&now, timebuf); + TIZEN_LOGI("[Certificate] TV borad time is: %s", timebuf); + if (t != (time_t) -1) { + ctime_r(&t, timebuf); + TIZEN_LOGI("[Certificate] CA activation time is: %s", timebuf); + } + else + TIZEN_LOGI("[Certificate] gnutls_x509_crt_get_activation_time ERROR"); #endif if (t == (time_t) -1 || t > now) @@ -387,7 +387,7 @@ g_tls_certificate_gnutls_verify (GTlsCertificate *cert, t = gnutls_x509_crt_get_expiration_time (chain[i]); -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_TV_ADJUST_TIME) && ENABLE(TIZEN_DLOG) if (t != (time_t) -1) { ctime_r(&t, timebuf); TIZEN_LOGI("[Certificate] CA expiration time is: %s", timebuf); @@ -605,7 +605,7 @@ g_tls_certificate_gnutls_verify_identity (GTlsCertificateGnutls *gnutls, /* FIXME: check sRVName and uniformResourceIdentifier * subjectAltNames, if appropriate for @identity. */ -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_DLOG) TIZEN_LOGI("[Network] SSL HandShake - Bad Identity"); #endif diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c index e98bc7e..d4b1ea9 100755 --- a/tls/gnutls/gtlsconnection-gnutls.c +++ b/tls/gnutls/gtlsconnection-gnutls.c @@ -1117,7 +1117,7 @@ verify_peer_certificate (GTlsConnectionGnutls *gnutls, if (database == NULL) { -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_DLOG) TIZEN_LOGI("[Network] SSL HandShake - Unknown CA"); #endif diff --git a/tls/gnutls/gtlsdatabase-gnutls.c b/tls/gnutls/gtlsdatabase-gnutls.c index 018639f..448ddb8 100755 --- a/tls/gnutls/gtlsdatabase-gnutls.c +++ b/tls/gnutls/gtlsdatabase-gnutls.c @@ -175,7 +175,7 @@ double_check_before_after_dates (GTlsCertificateGnutls *chain) GTlsCertificateFlags gtls_flags = 0; gnutls_x509_crt_t cert; time_t t, now; -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_TV_ADJUST_TIME) && ENABLE(TIZEN_DLOG) char timebuf[256]; #endif @@ -190,7 +190,7 @@ double_check_before_after_dates (GTlsCertificateGnutls *chain) cert = g_tls_certificate_gnutls_get_cert (chain); t = gnutls_x509_crt_get_activation_time (cert); -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_TV_ADJUST_TIME) && ENABLE(TIZEN_DLOG) ctime_r(&now, timebuf); TIZEN_LOGI("[Certificate] TV borad time is: %s", timebuf); if (t != (time_t) -1) { @@ -206,7 +206,7 @@ double_check_before_after_dates (GTlsCertificateGnutls *chain) t = gnutls_x509_crt_get_expiration_time (cert); -#if ENABLE(TIZEN_TV_DLOG) +#if ENABLE(TIZEN_TV_ADJUST_TIME) && ENABLE(TIZEN_DLOG) if (t != (time_t) -1) { ctime_r(&t, timebuf); TIZEN_LOGI("[Certificate] CA expiration time is: %s", timebuf); -- 2.7.4