Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass multiple CA certificates to ssl_pem_contents ? #273

Open
hunter86bg opened this issue Aug 30, 2022 · 4 comments
Open

How to pass multiple CA certificates to ssl_pem_contents ? #273

hunter86bg opened this issue Aug 30, 2022 · 4 comments

Comments

@hunter86bg
Copy link

I am trying to pass multiple CA certificates to ssl_pem_contents as I never know which CA will sign the vault's certificate. Yet, I receive:

FATAL: OpenSSL::PKey::RSAError: read_vault[Read secret at secret/my-app] (secret::create_secret line 38) had an error: OpenSSL::PKey::RSAError: Neither PUB key nor PRIV key: nested asn1 error

How can I make this one work?

require 'vault'
cert_content = ""
Dir.glob(['/etc/ssl/certs/*.crt','/etc/ssl/certs/*.pem','/etc/chef/trusted_certs/*']).each do |cert|
  cert_content += ::File.open(cert).read
end

Vault.configure do |config|
  config.ssl_pem_contents = cert_content
end
@hunter86bg
Copy link
Author

So far my workaround (should work on RHEL/SLES) is:

require 'tempfile'
temp_cert_file = Tempfile.new('csv', '/etc/chef/')
Dir.glob(['/etc/ssl/certs/*.crt', '/etc/ssl/certs/*.pem', '/etc/chef/trusted_certs/*']).each do |ca_cert|
  IO.copy_stream(ca_cert, temp_cert_file)
end
ENV['SSL_CERT_FILE'] = temp_cert_file.path
require 'vault'

@jackivanov
Copy link

Vault.ssl_ca_cert = '/etc/ssl/certs/ca-certificates.crt'

ssl_ca_cert seems to be working fine with multiple certs

@hunter86bg
Copy link
Author

@jackivanov,
in Chef you can have multiple files in a directory. Is there a way to point to a directory instead of a file ?

@jackivanov
Copy link

@hunter86bg yes, there's ssl_ca_path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants