openapi-typescript
openapi-typescript copied to clipboard
allow self signed certificate when reading spec from remote
openapi-typescript https://1.1.1.1/admin/swagger/doc.json --output petstore.ts
output
✨ openapi-typescript 5.1.1
(node:29072) UnhandledPromiseRejectionWarning: Error: unable to verify the first certificate
Having the same issue, any updates on this?
On Node.js v18.6.0, when I use command:
$ npx openapi-typescript https://localhost:4430/doc-json --output betApi.ts
throw this error:
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
Error: self-signed certificate
at TLSSocket.onConnectSecure (node:_tls_wrap:1534:34)
at TLSSocket.emit (node:events:513:28)
at TLSSocket._finishInit (node:_tls_wrap:948:8)
at ssl.onhandshakedone (node:_tls_wrap:729:12) {
code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
}
I found to node don't throw this error We can add a flag::
NODE_TLS_REJECT_UNAUTHORIZED='0'
so in bash, I used this command:
$ NODE_TLS_REJECT_UNAUTHORIZED='0' npx openapi-typescript https://localhost:4430/doc-json --output betApi.ts
and it, for me work 👍
Have the same issue on windows. So i can't pass NODE_TLS_REJECT_UNAUTHORIZED='0'
like in a bash.
Any updates on it?
Any updates on this please?
export NODE_TLS_REJECT_UNAUTHORIZED=0 - Mac
set NODE_TLS_REJECT_UNAUTHORIZED=0 - windows
export NODE_TLS_REJECT_UNAUTHORIZED=0 - linux
https://stackoverflow.com/questions/68592669/how-to-set-value-for-node-tls-reject-unauthorized-0-in-mac
In 5.x and 6.x, fetching is handled by undici. Undici has added self-signed certificates support (docs), and I’d be open to adding a CLI flag that passes this along.
However, in 7.x, the Redocly CLI is doing the schema fetching, and I think that doesn’t support it either, as indicated in this open issue.
As much as I’d hate to introduce a new feature to 6.x right before it becomes obsolete in the next month or so, maybe we add it anyway, and work with Redocly to add it to the CLI so everyone wins
This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.
This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.