daily pastebin goal
37%
SHARE
TWEET

X509 with embedded X509, ruby problem

a guest Feb 8th, 2014 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env ruby
  2.  
  3. require 'openssl'
  4.  
  5. certb64 = "MIIGnjCCBgegAwIBAgIIEm6CDAAAAAAwDQYJKoZIhvcNAQEFBQAwgYkxCzAJBgNVBAYTAk5PMR0wGwYDVQQIExRUYW5kYmVyZ0RlZmF1bHRTdGF0ZTEcMBoGA1UEBxMTVGFuZGJlcmdEZWZhdWx0Q2l0eTEtMCsGA1UEChMkUHJveHlTRzogVGVtcG9yYXJ5RGVmYXVsdENlcnRpZmljYXRlMQ4wDAYDVQQDEwVDaXNjbzAeFw0xMjAxMjUxODM2MDlaFw0zMjAxMjAxODM2MDlaMIGAMQswCQYDVQQGEwJOTzEdMBsGA1UECBMUVGFuZGJlcmdEZWZhdWx0U3RhdGUxHDAaBgNVBAcTE1RhbmRiZXJnRGVmYXVsdENpdHkxJDAiBgNVBAoTG1RlbXBvcmFyeURlZmF1bHRDZXJ0aWZpY2F0ZTEOMAwGA1UEAxMFQ2lzY28wgZ0wDQYJKoZIhvcNAQEBBQADgYsAMIGHAoGBAMRhzS8PT1XklwZhAsk79HNDs+CEJFvc7SmhrCmkUQ52rEhFEGS5vkJNq+rY8/iAQWr4TAIC64SzoVNtyqtxsb9oyCaRxQGew8P6588dJumAdo8qLI8LBUU3Mrv5cWBoFUyNj7o24Hl+rYfYD0zIUr4uYqYOMCHBa76KWM3Al1MpAgEDo4IEFjCCBBIwCQYDVR0TBAIwADALBgNVHQ8EBAMCBeAwHwYDVR0jBBgwFoAUQ96VNqbujQTyrzkQ4WKEdaLJS6swggPCBglghkgBhvhCAQ0EggOzFoIDrwpPcmlnaW5hbCBjZXJ0aWZpY2F0ZToKLS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNlVENDQWVJQ0NRQ0FsN0ZXTlJFNW56QU5CZ2txaGtpRzl3ME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TM3V240cEZsakRuMWIvWm0KcXNSTnFucVd4MUR4ckZuSWJ3PT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQowEQYDVR0gBAowCDAGBgRVHSAAMA0GCSqGSIb3DQEBBQUAA4GBAGJzh6GI3y8UgYFpzwdrzvXmCSwfHwcL0ZIXVvdhvB86LwmKOS7hwe5zN3sv7dwIKHVoEnoSiGDWPaTKqu4gAyO2KqYf2hANSNvhXWfy5OctsoUJPlPH21oCvO4l7/uQPF6YLRJn+174y/+dXy+SYevxM0OhZQwAlKa0fzKHjwCf"
  6.  
  7. cert = certb64.unpack("m*").first
  8. puts Digest::SHA1.hexdigest(cert)
  9.  
  10. x509 = OpenSSL::X509::Certificate.new(cert)
  11. puts Digest::SHA1.hexdigest(x509.to_der)
  12. puts "these should be the same"
RAW Paste Data
Top