Skip to content

Commit 804ab42

Browse files
authored
Add support for Http client cert and key to support mTLS (#3100)
1 parent f6bc670 commit 804ab42

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

gems/aws-sdk-core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Add support for `ssl_cert` and `ssl_key` configuration options to support mTLS.
5+
46
3.203.0 (2024-09-03)
57
------------------
68

gems/aws-sdk-core/lib/seahorse/client/net_http/connection_pool.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class ConnectionPool
3434
ssl_ca_bundle: nil,
3535
ssl_ca_directory: nil,
3636
ssl_ca_store: nil,
37-
ssl_timeout: nil
37+
ssl_timeout: nil,
38+
ssl_cert: nil,
39+
ssl_key: nil
3840
}
3941

4042
# @api private
@@ -246,7 +248,9 @@ def pool_options options
246248
:ssl_ca_bundle => options[:ssl_ca_bundle],
247249
:ssl_ca_directory => options[:ssl_ca_directory],
248250
:ssl_ca_store => options[:ssl_ca_store],
249-
:ssl_timeout => options[:ssl_timeout]
251+
:ssl_timeout => options[:ssl_timeout],
252+
:ssl_cert => options[:ssl_cert],
253+
:ssl_key => options[:ssl_key]
250254
}
251255
end
252256

@@ -291,6 +295,8 @@ def start_session endpoint
291295
http.ca_file = ssl_ca_bundle if ssl_ca_bundle
292296
http.ca_path = ssl_ca_directory if ssl_ca_directory
293297
http.cert_store = ssl_ca_store if ssl_ca_store
298+
http.cert = ssl_cert if ssl_cert
299+
http.key = ssl_key if ssl_key
294300
else
295301
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
296302
end

gems/aws-sdk-core/lib/seahorse/client/plugins/net_http.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ class NetHttp < Plugin
7070
resolve_ssl_timeout(cfg)
7171
end
7272

73+
option(:ssl_cert, default: nil, doc_type: OpenSSL::X509::Certificate, docstring: <<-DOCS)
74+
Sets a client certificate when creating http connections.
75+
DOCS
76+
77+
78+
option(:ssl_key, default: nil, doc_type: OpenSSL::PKey, docstring: <<-DOCS)
79+
Sets a client key when creating http connections.
80+
DOCS
81+
7382
option(:logger) # for backwards compat
7483

7584
handler(Client::NetHttp::Handler, step: :send)

gems/aws-sdk-core/spec/seahorse/client/plugins/net_http_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ module Plugins
102102
it 'adds a :ssl_ca_store option without default' do
103103
expect(config.ssl_ca_store).to eq(nil)
104104
end
105+
106+
it 'adds a :ssl_cert option with no default' do
107+
expect(config.ssl_cert).to eq(nil)
108+
end
109+
110+
it 'adds a :ssl_key option with no default' do
111+
expect(config.ssl_key).to eq(nil)
112+
end
105113
end
106114

107115
describe '#add_handlers' do

0 commit comments

Comments
 (0)