Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env ruby -w
require 'net/http'
require 'net/https'
require 'openssl'
require 'uri'
DIR = File.dirname(__FILE__)
uri = URI.parse("https://test.directory.securecode.com:443/")
https = Net::HTTP.new(uri.host, uri.port)
https.cert = OpenSSL::X509::Certificate.new(File.read("#{DIR}/28143-VALFAC-MPIclient.crt"))
https.key = OpenSSL::PKey::RSA.new(File.read("#{DIR}/28143-VALFAC-MPIclient.key"))
https.ca_file = "#{DIR}/VALFAC-trustedroot.pem"
https.use_ssl = true
https.read_timeout = 30
#raise 'certificate can not be verified' unless https.cert.verify https.key
req = Net::HTTP::Post.new(uri.request_uri)
req.body = File.read("#{DIR}/vereq.xml")
req.content_type = 'application/x-www-form-urlencoded'
res = https.request(req)
p res.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment