-
-
Save hh/4323170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'base64' | |
publishfile = Dir.glob('*publishsettings').first | |
publishxml = open(publishfile).read | |
cert_base64 = /(?<=ManagementCertificate=\")(?<cert>.*)\">/.match(publishxml)['cert'] | |
cert_pks12 = Base64.decode64(cert_base64) | |
cert = OpenSSL::PKCS12.new cert_pks12 | |
#cert.certificate | |
#=> #<OpenSSL::X509::Certificate subject=/CN=Windows Azure Tools, | |
# issuer=/CN=Windows Azure Tools, serial=146843026396629116628912196159077583730, | |
# not_before=2012-12-17 22:05:25 UTC, not_after=2013-12-17 22:05:25 UTC> | |
# We could probably just drop the publishsettings file into .chef and detect it automatically | |
open("#{publishfile.sub(/publishsettings/,'pem')}",'wb').write cert.certificate.to_pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This may be an easier approach to using azure certificates