Created
May 6, 2014 02:10
-
-
Save trlinkin/be1f6e2fbf6c452db3e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'yaml' | |
| pol_file = File.join(File.dirname(__FILE__),"auths.yaml") | |
| pol = YAML.load(File.read(pol_file)) | |
| csr = OpenSSL::X509::Request.new STDIN.read | |
| pw = nil | |
| id_oid = pol[:id_oid] | |
| id = nil | |
| extentions = Hash.new | |
| csr.attributes.each do |attr| | |
| pw = attr.value.first.value if attr.oid == 'challengePassword' | |
| if attr.oid == 'extReq' | |
| extraw = attr.value.first.value.map(&:value) | |
| index = -1 | |
| extraw.map do |ext| | |
| index += 1 | |
| ev = OpenSSL::X509::Extension.new(ext[0].value, ext[1].value) | |
| extentions[ev.oid] = ev.value | |
| end | |
| end | |
| end | |
| id = extentions[id_oid] | |
| puts | |
| if pw and id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment