enonic / lib-http-client

Http Client Library for Enonic XP.
Apache License 2.0
0 stars 4 forks source link

mTLS support #59

Closed rymsha closed 3 years ago

rymsha commented 3 years ago

Provide a way to specify client certificate, similar to how curl --cert option does.

rymsha commented 3 years ago

Limitations:

rymsha commented 3 years ago

Test

-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHN18R6x5Oz+u6
...
GTH3fhaM/pZZGdIC75x/69Y=
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIEqDCCApCgAwIBAgIUK5Ns4y2CzosB/ZoFlaxjZqoBTIIwDQYJKoZIhvcNAQEL
...
g0Y2YBH5v0xmi8sYU7weOcwynkjZARpUltBUQ0pWCF5uJsEB8uE8PPDD3c4=
-----END CERTIFICATE-----

run

 var clientCertificate = io.newStream(/*clientCertificate string goes here*/)
  var result = http.request({
      url: 'https://client.badssl.com',
      clientCertificate: clientCertificate
  });
  log.info(JSON.stringify(result))

resutl.status should be 200