lib/saml/util.rb in libsaml-2.1.3 vs lib/saml/util.rb in libsaml-2.1.4
- old
+ new
@@ -13,19 +13,30 @@
params
end
def post(location, message, additional_headers = {})
- request = HTTPI::Request.new
+ uri = URI.parse(location)
- request.url = location
- request.headers.merge! additional_headers
- request.headers['Content-Type'] = 'text/xml'
- request.body = message
- request.auth.ssl.cert_file = Saml::Config.ssl_certificate_file
- request.auth.ssl.cert_key_file = Saml::Config.ssl_private_key_file
+ http = Net::HTTP.new(uri.host, uri.port)
+ http.use_ssl = true
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
- HTTPI.post request
+ if Saml::Config.ssl_certificate_file.present? && Saml::Config.ssl_private_key_file.present?
+ cert = File.read(Saml::Config.ssl_certificate_file)
+ key = File.read(Saml::Config.ssl_private_key_file)
+
+ http.cert = OpenSSL::X509::Certificate.new(cert)
+ http.key = OpenSSL::PKey::RSA.new(key)
+ end
+
+ headers = { 'Content-Type' => 'text/xml' }
+ headers.merge! additional_headers
+
+ request = Net::HTTP::Post.new(uri.request_uri, headers)
+ request.body = message
+
+ http.request(request)
end
def sign_xml(message, format = :xml, &block)
message.add_signature