Skip to content

axios Error: self signed certificate #174

@fairking

Description

@fairking

Hi,

I am having an issue with one of my projects:

C:\Code\MyProject>npm run codegen loaded spec document fail! https://localhost:8050/api/shared/schema.json Error: self signed certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1532:34) at TLSSocket.emit (node:events:527:28) at TLSSocket._finishInit (node:_tls_wrap:946:8) at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:727:12) { code: 'DEPTH_ZERO_SELF_SIGNED_CERT' } 

As a workaround I have added the following lines in \swagger-axios-codegen\src\index.ts

const https = require('https'); // and then line 54: const { data: swaggerJson } = await axios({ url: params.remoteUrl, responseType: 'text', httpsAgent: new https.Agent({ rejectUnauthorized: false }) })

see httpsAgent: new https.Agent({ rejectUnauthorized: false })

I am not sure how others solve such issue, but if it would cause any problems we can introduce an option 'ISwaggerOptions.allowSelfSignedCert' which by default would be false. I can create a PR if the change is wanted by others.

Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions