Skip to content

Commit 6a3108a

Browse files
committed
Support client ceritficate in ruby client
1 parent 2ea3816 commit 6a3108a

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

modules/swagger-codegen/src/main/resources/ruby/api_client.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ module {{moduleName}}
7070
:headers => header_params,
7171
:params => query_params,
7272
:ssl_verifypeer => Configuration.verify_ssl,
73+
:sslcert => Configuration.cert_file,
74+
:sslkey => Configuration.key_file,
7375
:cainfo => Configuration.ssl_ca_cert,
7476
:verbose => Configuration.debugging
7577
}

modules/swagger-codegen/src/main/resources/ruby/configuration.mustache

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module {{moduleName}}
6464
# @return [String]
6565
attr_accessor :temp_folder_path
6666

67+
### TLS/SSL
6768
# Set this to false to skip verifying SSL certificate when calling API from https server.
6869
# Default to true.
6970
#
@@ -80,6 +81,12 @@ module {{moduleName}}
8081
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
8182
attr_accessor :ssl_ca_cert
8283

84+
# Client certificate file (for client certificate)
85+
attr_accessor :cert_file
86+
87+
# Client private key file (for client certificate)
88+
attr_accessor :key_file
89+
8390
attr_accessor :inject_format
8491

8592
attr_accessor :force_ending_format
@@ -102,6 +109,8 @@ module {{moduleName}}
102109
@api_key = {}
103110
@api_key_prefix = {}
104111
@verify_ssl = true
112+
@cert_file = nil
113+
@key_file = nil
105114
@debugging = false
106115
@inject_format = false
107116
@force_ending_format = false

samples/client/petstore/ruby/lib/petstore/api_client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def build_request(http_method, path, opts = {})
7070
:headers => header_params,
7171
:params => query_params,
7272
:ssl_verifypeer => Configuration.verify_ssl,
73+
:sslcert => Configuration.cert_file,
74+
:sslkey => Configuration.key_file,
7375
:cainfo => Configuration.ssl_ca_cert,
7476
:verbose => Configuration.debugging
7577
}

samples/client/petstore/ruby/lib/petstore/configuration.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Configuration
6464
# @return [String]
6565
attr_accessor :temp_folder_path
6666

67+
### TLS/SSL
6768
# Set this to false to skip verifying SSL certificate when calling API from https server.
6869
# Default to true.
6970
#
@@ -80,6 +81,12 @@ class Configuration
8081
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
8182
attr_accessor :ssl_ca_cert
8283

84+
# Client certificate file (for client certificate)
85+
attr_accessor :cert_file
86+
87+
# Client private key file (for client certificate)
88+
attr_accessor :key_file
89+
8390
attr_accessor :inject_format
8491

8592
attr_accessor :force_ending_format
@@ -102,6 +109,8 @@ def initialize
102109
@api_key = {}
103110
@api_key_prefix = {}
104111
@verify_ssl = true
112+
@cert_file = nil
113+
@key_file = nil
105114
@debugging = false
106115
@inject_format = false
107116
@force_ending_format = false

0 commit comments

Comments
 (0)