class Sourcefire::PkcsOps
Attributes
cert[RW]
key[RW]
Public Instance Methods
cert_der(strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 53 def cert_der(strip_header_footer = false) processed_cert = strip_header_footer ? p12_data_to_split_string(@cert.to_der) {|data| data.to_a[1..-2].join} : @cert processed_cert.nil? ? 'No Cert Data!' : processed_cert end
cert_der_to_file(file_name, strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 33 def cert_der_to_file(file_name, strip_header_footer = false) processed_cert = strip_header_footer ? p12_data_to_split_string(@cert.to_der) {|data| data.to_a[1..-2].join} : @cert File.open(file_name, 'w') {|f| processed_cert.nil? ? f.write('No Cert Data!') : f.write(processed_cert) } end
cert_pem(strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 48 def cert_pem(strip_header_footer = false) processed_cert = strip_header_footer ? p12_data_to_split_string(@cert.to_pem) {|data| data.to_a[1..-2].join} : @cert processed_cert.nil? ? 'No Cert Data!' : processed_cert end
cert_pem_to_file(file_name, strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 28 def cert_pem_to_file(file_name, strip_header_footer = false) processed_cert = strip_header_footer ? p12_data_to_split_string(@cert.to_pem) {|data| data.to_a[1..-2].join} : @cert File.open(file_name, 'w') {|f| processed_cert.nil? ? f.write('No Cert Data!') : f.write(processed_cert) } end
cert_public_key(strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 58 def cert_public_key(strip_header_footer = false) strip_header_footer ? p12_data_to_split_string(@cert.public_key) {|data| data.to_a[1..-2].join} : @cert.public_key end
extract_pkcs_12(pkcs_file, password = nil)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 8 def extract_pkcs_12(pkcs_file, password = nil) if password.nil? || password.empty? p12 = OpenSSL::PKCS12.new(File.read(pkcs_file)) else p12 = OpenSSL::PKCS12.new(File.read(pkcs_file), password) end @key = p12.key @cert = p12.certificate end
key_to_file(file_name, strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 18 def key_to_file(file_name, strip_header_footer = false) processed_key = strip_header_footer ? p12_data_to_split_string(@key) {|data| data.to_a[1..-2].join} : @key File.open(file_name, 'w') {|f| processed_key.nil? ? f.write('No Key Data!') : f.write(processed_key) } end
raw_cert(strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 43 def raw_cert(strip_header_footer = false) processed_cert = strip_header_footer ? p12_data_to_split_string(@cert) {|data| data.to_a[1..-2].join} : @cert processed_cert.nil? ? 'No Cert Data!' : processed_cert end
raw_cert_to_file(file_name, strip_header_footer = false)
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 23 def raw_cert_to_file(file_name, strip_header_footer = false) processed_cert = strip_header_footer ? p12_data_to_split_string(@cert) {|data| data.to_a[1..-2].join} : @cert File.open(file_name, 'w') {|f| processed_cert.nil? ? f.write('No Cert Data!') : f.write(processed_cert) } end
Private Instance Methods
p12_data_to_split_string(data) { |data.lines| ... }
click to toggle source
# File lib/sourcefire/p12_utils.rb, line 63 def p12_data_to_split_string(data) yield data.to_s.strip.lines end