1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2025, by Samuel Williams.
module Localhost
module System
# Darwin specific system operations.
module Darwin
# Install a certificate into the system trust store.
#
# @parameter certificate [String] The path to the certificate file.
def self.install(certificate)
login_keychain = File.expand_path("~/Library/Keychains/login.keychain-db")
success = system(
"security", "add-trusted-cert",
"-d", "-r", "trustRoot",
"-k", login_keychain,
certificate
)
if success
$stderr.puts "Installed certificate to #{login_keychain}"
return true
else
raise "Failed to install certificate: #{certificate}"
end
end
end
end
end
|