Skip to content

Instantly share code, notes, and snippets.

@drymar
Forked from hoverlover/savon_client.rb
Created July 3, 2016 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drymar/1a37798a03fbf88fe94d6f9e5be603d9 to your computer and use it in GitHub Desktop.
Save drymar/1a37798a03fbf88fe94d6f9e5be603d9 to your computer and use it in GitHub Desktop.
Using my forks of Akami and Savon to sign a request with a X.509 certificate. See https://github.com/genuitytech/akami and https://github.com/genuitytech/savon.
client = Savon::Client.new do
# This can be a URL also
wsdl.document = "/Path/to/your.wsdl"
# These are optional, only if your WSDL sucks :)
wsdl.endpoint = "https://your_endpoint"
wsdl.namespace = "http://your_namespace"
certs = Akami::WSSE::Certs.new :cert_file => "/path/to/cert.crt", :private_key_file => "/path/to/private/key.pem", :private_key_password => "password"
wsse.sign_with = Akami::WSSE::Signature.new certs
# SSL certs, if you need them
http.auth.ssl.tap do |ssl|
ssl.cert_file = "/path/to/signing/cert.crt"
ssl.cert_key_file = "/path/to/signing/private.key"
ssl.cert_key_password = "password"
ssl.ca_cert_file = "/path/to/signing/ca.crt"
end
end
# soap_action is optional
res = client.request :namespace_identifier, :element, soap_action: :action do
soap.element_form_default = :qualified
soap.body = {
element1: 'foo',
element2: 'bar'
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment