Skip to content

Commit 3831af4

Browse files
committed
(ITHELP-98367) - Fix AiTM attacks vulnerability
1 parent 7798c27 commit 3831af4

File tree

6 files changed

+26
-18
lines changed

6 files changed

+26
-18
lines changed

tasks/backup_classification.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def https_client
2424
client.use_ssl = true
2525
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
2626
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
27-
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
27+
client.verify_mode = OpenSSL::SSL::VERIFY_PEER
28+
client.ca_file = Puppet.settings[:localcacert]
2829
client
2930
end
3031

tasks/code_sync_status.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def https_client
2323
client.use_ssl = true
2424
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
2525
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
26-
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
26+
client.verify_mode = OpenSSL::SSL::VERIFY_PEER
27+
client.ca_file = Puppet.settings[:localcacert]
2728
client
2829
end
2930

tasks/get_peadm_config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def https(port)
105105
https.use_ssl = true
106106
https.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
107107
https.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
108-
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
108+
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
109+
https.ca_file = Puppet.settings[:localcacert]
109110
https
110111
end
111112

tasks/pe_ldap_config.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ def main
3232
end
3333

3434
uri = URI("https://#{pe_main}:4433/rbac-api/v1/ds")
35-
http = Net::HTTP.new(uri.host, uri.port)
36-
http.use_ssl = true
37-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
38-
http.ca_file = cafout.strip
39-
http.cert = OpenSSL::X509::Certificate.new(File.read(certout.strip))
40-
http.key = OpenSSL::PKey::RSA.new(File.read(keyout.strip))
35+
https = Net::HTTP.new(uri.host, uri.port)
36+
https.use_ssl = true
37+
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
38+
https.ca_file = cafout.strip
39+
https.cert = OpenSSL::X509::Certificate.new(File.read(certout.strip))
40+
https.key = OpenSSL::PKey::RSA.new(File.read(keyout.strip))
4141

4242
req = Net::HTTP::Put.new(uri, 'Content-type' => 'application/json')
4343
req.body = data.to_json
4444

45-
resp = http.request(req)
45+
resp = https.request(req)
4646

4747
puts resp.body
4848
raise "API response code #{resp.code}" unless resp.code == '200'

tasks/puppet_infra_upgrade.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
require 'open3'
88
require 'timeout'
99
require 'etc'
10+
require 'puppet'
1011

1112
# Class to run and execute the `puppet infra upgrade` command as a task.
1213
class PuppetInfraUpgrade
@@ -57,21 +58,24 @@ def request_object(nodes:, token_file:)
5758
request
5859
end
5960

60-
def http_object
61-
http = Net::HTTP.new(inventory_uri.host, inventory_uri.port)
62-
http.use_ssl = true
63-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
61+
def https_object
62+
https = Net::HTTP.new(inventory_uri.host, inventory_uri.port)
63+
https.use_ssl = true
64+
https.cert = OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
65+
https.key = OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
66+
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
67+
https.ca_file = Puppet.settings[:localcacert]
6468

65-
http
69+
https
6670
end
6771

6872
def wait_until_connected(nodes:, token_file:, timeout: 120)
69-
http = http_object
73+
https = https_object
7074
request = request_object(nodes: nodes, token_file: token_file)
7175
inventory = {}
7276
Timeout.timeout(timeout) do
7377
loop do
74-
response = http.request(request)
78+
response = https.request(request)
7579
unless response.is_a? Net::HTTPSuccess
7680
raise "Unexpected result from orchestrator: #{response.class}\n#{response}"
7781
end

tasks/restore_classification.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def https_client
2424
client.use_ssl = true
2525
client.cert = @cert ||= OpenSSL::X509::Certificate.new(File.read(Puppet.settings[:hostcert]))
2626
client.key = @key ||= OpenSSL::PKey::RSA.new(File.read(Puppet.settings[:hostprivkey]))
27-
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
27+
client.verify_mode = OpenSSL::SSL::VERIFY_PEER
28+
client.ca_file = Puppet.settings[:localcacert]
2829
client
2930
end
3031

0 commit comments

Comments
 (0)