Skip to content

Instantly share code, notes, and snippets.

@nmattam
Forked from acharlieh/script.rb
Created September 19, 2016 22:02
Show Gist options
  • Save nmattam/30cbecb0156d8e77e045e168f88fd5ad to your computer and use it in GitHub Desktop.
Save nmattam/30cbecb0156d8e77e045e168f88fd5ad to your computer and use it in GitHub Desktop.
Figuring out that one vagrant vault key wasn't updated
require 'chef-vault'
data = JSON.parse(File.open('data_bags/cerner_splunk/license_secrets_keys.json').read())
keys = (data['clients'] + data['admins']).inject({}) do |m,c|
pem = (c == 'knife_workstation') ? 'fake-key.pem' : "pems/#{c}.pem"
private_key = OpenSSL::PKey::RSA.new(File.open(pem).read())
m[c] = private_key.private_decrypt(Base64.decode64(data[c]))
m
end
keys.each { |k,v| puts "'#{v.unpack('H*').join('')}'\t#{k}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment