Skip to content

Commit

Permalink
Merge pull request #266 from justincase/patch-1
Browse files Browse the repository at this point in the history
Request specific TLS version with additional constants
  • Loading branch information
taf2 committed Jan 20, 2016
2 parents 4a2183e + d769d64 commit b00f55e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions ext/curb.c
Expand Up @@ -296,6 +296,9 @@ void Init_curb_core() {
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1", INT2FIX(CURL_SSLVERSION_TLSv1));
rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", INT2FIX(CURL_SSLVERSION_SSLv2));
rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", INT2FIX(CURL_SSLVERSION_SSLv3));
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", INT2FIX(CURL_SSLVERSION_TLSv1_0));
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", INT2FIX(CURL_SSLVERSION_TLSv1_1));
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", INT2FIX(CURL_SSLVERSION_TLSv1_2));

rb_define_const(mCurl, "CURL_USESSL_CONTROL", INT2FIX(CURB_FTPSSL_CONTROL));
rb_define_const(mCurl, "CURL_USESSL_NONE", INT2FIX(CURB_FTPSSL_NONE));
Expand All @@ -306,6 +309,9 @@ void Init_curb_core() {
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1", INT2FIX(-1));
rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", INT2FIX(-1));
rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", INT2FIX(-1));
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", INT2FIX(-1));
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", INT2FIX(-1));
rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", INT2FIX(-1));

rb_define_const(mCurl, "CURL_USESSL_CONTROL", INT2FIX(-1));
rb_define_const(mCurl, "CURL_USESSL_NONE", INT2FIX(-1));
Expand Down Expand Up @@ -886,6 +892,15 @@ void Init_curb_core() {
#if HAVE_CURL_SSLVERSION_SSLv3
CURB_DEFINE(CURL_SSLVERSION_SSLv3);
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_0
CURB_DEFINE(CURL_SSLVERSION_TLSv1_0);
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_1
CURB_DEFINE(CURL_SSLVERSION_TLSv1_1);
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_2
CURB_DEFINE(CURL_SSLVERSION_TLSv1_2);
#endif
#if HAVE_CURLOPT_SSL_VERIFYPEER
CURB_DEFINE(CURLOPT_SSL_VERIFYPEER);
#endif
Expand Down
11 changes: 9 additions & 2 deletions ext/curb_easy.c
Expand Up @@ -1353,8 +1353,15 @@ static VALUE ruby_curl_easy_password_get(VALUE self, VALUE password) {
* easy.ssl_version = value => fixnum or nil
*
* Sets the version of SSL/TLS that libcurl will attempt to use. Valid
* options are Curl::CURL_SSLVERSION_TLSv1, Curl::CURL_SSLVERSION::SSLv2,
* Curl::CURL_SSLVERSION_SSLv3 and Curl::CURL_SSLVERSION_DEFAULT
* options are:
*
* Curl::CURL_SSLVERSION_DEFAULT
* Curl::CURL_SSLVERSION_TLSv1 (TLS 1.x)
* Curl::CURL_SSLVERSION_SSLv2
* Curl::CURL_SSLVERSION_SSLv3
* Curl::CURL_SSLVERSION_TLSv1_0
* Curl::CURL_SSLVERSION_TLSv1_1
* Curl::CURL_SSLVERSION_TLSv1_2
*/
static VALUE ruby_curl_easy_ssl_version_set(VALUE self, VALUE ssl_version) {
CURB_IMMED_SETTER(ruby_curl_easy, ssl_version, -1);
Expand Down
3 changes: 3 additions & 0 deletions ext/extconf.rb
Expand Up @@ -321,6 +321,9 @@ def have_constant(name)
have_constant :CURL_SSLVERSION_TLSv1
have_constant :CURL_SSLVERSION_SSLv2
have_constant :CURL_SSLVERSION_SSLv3
have_constant :CURL_SSLVERSION_TLSv1_0
have_constant :CURL_SSLVERSION_TLSv1_1
have_constant :CURL_SSLVERSION_TLSv1_2
have_constant "curlopt_ssl_verifypeer"
have_constant "curlopt_cainfo"
have_constant "curlopt_issuercert"
Expand Down

0 comments on commit b00f55e

Please sign in to comment.