OpenAPITools / OpenAPITools/openapi-generator
Problems with SSL certificate
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hi,
I try to use this CLI in my project to generate my API typescript client. But my swagger.yaml file is on a https url and I have errors because of SSL certificate.
I added the following script to my package.json :
"swagger": "./node_modules/.bin/openapi-generator generate -i https://myserver/api-docs -g typescript-fetch -o src/services/Api/swagger"
But when I run npm swagger I have the following stack trace :
[main] ERROR i.s.parser.SwaggerCompatConverter - failed to read resource listing javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
at io.swagger.parser.util.RemoteUrl.urlToString(RemoteUrl.java:134)
at io.swagger.parser.SwaggerCompatConverter.readResourceListing(SwaggerCompatConverter.java:193)
at io.swagger.parser.SwaggerCompatConverter.read(SwaggerCompatConverter.java:123)
at io.swagger.parser.SwaggerCompatConverter.readWithInfo(SwaggerCompatConverter.java:94)
at io.swagger.parser.SwaggerParser.readWithInfo(SwaggerParser.java:42)
at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:92)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:19)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:606)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:367)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60) Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) ... 21 common frames omitted
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
... 27 common frames omitted
Exception in thread "main" java.lang.NullPointerException
at java.util.HashSet.(Unknown Source)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:608)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:367)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
--
Any idea how I could solve this ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the package.json command against the HTTPS swagger.yaml URL, then trace the failure through io.swagger.parser.util.RemoteUrl.urlToString, SwaggerCompatConverter, OpenAPIParser, and CodegenConfigurator as shown in the stack trace. Establish the expected handling for the certificate error and verify that the generator no longer fails with the reported handshake and NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, typescript
- Domain
- api, devtools, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100