You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 10, 2024. It is now read-only.
When trying to proxy requests against a https secured API endpoint I'm getting this error message.
node bin/osprey.js -f api.raml -a https://api.example.org -p 3000
Error: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:*.example.org, DNS:example.org"<br> at Object.checkServerIdentity (tls.js:199:15)<br> at TLSSocket.<anonymous> (_tls_wrap.js:1066:29)<br> at emitNone (events.js:86:13)<br> at TLSSocket.emit (events.js:185:7)<br> at TLSSocket._finishInit (_tls_wrap.js:584:8)<br> at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38)
First I thought I might fix this issue by enabling CORS, but this didn't helped. Actually I had to set the environment variable NODE_TLS_REJECT_UNAUTHORIZED=0 in order to do so.
To avoid setting the environment variable it's possible to just set the host in the request header to the target address
function createProxy (middleware, addresses) {
var fns = []
var addrs = arrify(addresses).map(function (address) {
var addr = url.format(address)
return /^\w+:\/\//.test(addr) ? addr : 'http://' + addr
})
fns.push(middleware)
fns.push(function proxyAddress (req, res, next) {
var addr = addrs.shift()
var opts = url.parse(url.resolve(addr, req.url))
opts.headers.host = 'api.example.org' // just hardcoded this part for testing purposes
Then the request is directly accepted.
The text was updated successfully, but these errors were encountered:
This looks like a legit error coming from NodeJS. TLS validates the certificates and since https://api.example.org doesn't resolve/exist, there is not certificate to validate. Have you tried passing a valid (https) URL to -a?
Yes. It‘s not about the invalid uri. As the error is saying it can‘t authenticate localhost.
Osprey is no full http proxy. It‘s more an API gateway. So when trying to route traffic through osprey I use the localhost:3000 as my target API uri. And osprey should proxy valid traffic to the uri provided in the -a flag.
But as osprey is not correcting the http headers the proxying does not work when trying to connect to real APIs using https
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When trying to proxy requests against a https secured API endpoint I'm getting this error message.
First I thought I might fix this issue by enabling CORS, but this didn't helped. Actually I had to set the environment variable
NODE_TLS_REJECT_UNAUTHORIZED=0
in order to do so.To avoid setting the environment variable it's possible to just set the host in the request header to the target address
Then the request is directly accepted.
The text was updated successfully, but these errors were encountered: