Commit d4ccf7cc4455b67af729eabebfa289ebd343fbca

Authored by Perry Werneck
1 parent c88f821b

Adding getter/setter/init for the minimum and maximum SSL protocol

versions.
src/core/properties/signed.c
@@ -49,6 +49,48 @@ @@ -49,6 +49,48 @@
49 return (int) lib3270_get_ssl_state(hSession); 49 return (int) lib3270_get_ssl_state(hSession);
50 } 50 }
51 51
  52 + static int lib3270_set_ssl_minimum_supported_version(H3270 *hSession, int value)
  53 + {
  54 +#ifdef HAVE_LIBSSL
  55 + FAIL_IF_ONLINE(hSession);
  56 + hSession->ssl.supported_version.minimum = value;
  57 + return 0;
  58 +#else
  59 + return ENOTSUP;
  60 +#endif // HAVE_LIBSSL
  61 + }
  62 +
  63 + static int lib3270_set_ssl_maximum_supported_version(H3270 *hSession, int value)
  64 + {
  65 +#ifdef HAVE_LIBSSL
  66 + FAIL_IF_ONLINE(hSession);
  67 + hSession->ssl.supported_version.maximum = value;
  68 + return 0;
  69 +#else
  70 + return ENOTSUP;
  71 +#endif // HAVE_LIBSSL
  72 + }
  73 +
  74 + static int lib3270_get_ssl_minimum_supported_version(const H3270 *hSession)
  75 + {
  76 +#ifdef HAVE_LIBSSL
  77 + return hSession->ssl.supported_version.minimum;
  78 +#else
  79 + errno = ENOTSUP;
  80 + return 0;
  81 +#endif // HAVE_LIBSSL
  82 + }
  83 +
  84 + static int lib3270_get_ssl_maximum_supported_version(const H3270 *hSession)
  85 + {
  86 +#ifdef HAVE_LIBSSL
  87 + return hSession->ssl.supported_version.maximum;
  88 +#else
  89 + errno = ENOTSUP;
  90 + return 0;
  91 +#endif // HAVE_LIBSSL
  92 + }
  93 +
52 const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) 94 const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void)
53 { 95 {
54 96
@@ -75,6 +117,22 @@ @@ -75,6 +117,22 @@
75 .set = NULL // Set value. 117 .set = NULL // Set value.
76 }, 118 },
77 119
  120 + {
  121 + .name = "ssl_minimum_version", // Property name.
  122 + .description = N_( "ID of the minimum supported SSL version" ), // Property description.
  123 + .default_value = 0,
  124 + .get = lib3270_get_ssl_minimum_supported_version, // Get value.
  125 + .set = lib3270_set_ssl_minimum_supported_version // Set value.
  126 + },
  127 +
  128 + {
  129 + .name = "ssl_maximum_version", // Property name.
  130 + .description = N_( "ID of the maximum supported SSL version" ), // Property description.
  131 + .default_value = 0,
  132 + .get = lib3270_get_ssl_maximum_supported_version, // Get value.
  133 + .set = lib3270_set_ssl_maximum_supported_version // Set value.
  134 + },
  135 +
78 { 136 {
79 .name = NULL, 137 .name = NULL,
80 .description = NULL, 138 .description = NULL,
src/core/session.c
@@ -410,6 +410,11 @@ H3270 * lib3270_session_new(const char *model) @@ -410,6 +410,11 @@ H3270 * lib3270_session_new(const char *model)
410 hSession = lib3270_malloc(sizeof(H3270)); 410 hSession = lib3270_malloc(sizeof(H3270));
411 hSession->id = 0; 411 hSession->id = 0;
412 412
  413 +#ifdef HAVE_LIBSSL
  414 + hSession->ssl.supported_version.minimum = 0;
  415 + hSession->ssl.supported_version.maximum = 0;
  416 +#endif // HAVE_LIBSSL
  417 +
413 #ifdef SSL_ENABLE_CRL_CHECK 418 #ifdef SSL_ENABLE_CRL_CHECK
414 hSession->ssl.crl.download = 1; 419 hSession->ssl.crl.download = 1;
415 #endif // SSL_ENABLE_CRL_CHECK 420 #endif // SSL_ENABLE_CRL_CHECK
src/include/internals.h
@@ -662,6 +662,13 @@ struct _h3270 @@ -662,6 +662,13 @@ struct _h3270
662 char host; 662 char host;
663 LIB3270_SSL_STATE state; 663 LIB3270_SSL_STATE state;
664 unsigned long error; 664 unsigned long error;
  665 +
  666 + struct
  667 + {
  668 + int minimum; ///< @brief The minimum supported protocol version.
  669 + int maximum; ///< @brief The maximum supported protocol version.
  670 + } supported_version;
  671 +
665 #ifdef SSL_ENABLE_CRL_CHECK 672 #ifdef SSL_ENABLE_CRL_CHECK
666 struct 673 struct
667 { 674 {