landgraf-dev / openapi-delphi-generator

Generate Delphi client SDKs for any REST API defined with the OpenAPI specification.
Other
76 stars 13 forks source link

Server certificate error at request #5

Closed JDiegelmann closed 1 year ago

JDiegelmann commented 1 year ago

The importer worked fine!

When i tried do call a basic function of the imported api the request rises a certificate error ; when i use an tidhttp component on the form and i call the function it works. i don't know much about certificate managment, how cani fix the problem with the irestrequest calling?

wlandgraf commented 1 year ago

I guess you are running the imported API from an old Windows version? If that's the case, probably you have to enable TLS 1.2 in your Windows OS: https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/security/enable-tls-1-2-client

JDiegelmann commented 1 year ago

i tried it, but there is the same error again. i tried it on an windows 10 with delphi 10, and on an different pc with windows 10 with delphi 11.1 it raises an ENetHTTPCertificateException Exception in the unit system.net.httpclient in the DoValidateServerCertificate(LRequest: THTTPRequest) procedure

JDiegelmann commented 1 year ago

The error keeps. i tried it now with the TRest Komponents TRestclient, TRestRequest, TRestResponse. With this theres no error. When i use the irestrequest from your software i need a proper servercertificate, with the other comps i dont need it. im not able to solve it. but the convertes dtos and json converters worked fine.

wlandgraf commented 1 year ago

It doesn't much make sense as the generated code just uses Delphi THttpClient which is the same class used by TRestRequest. There is absolutely nothing regarding certificates, or authentication, or anything else there.

wlandgraf commented 1 year ago

We have updated the client libraries so that after the client is generated, users can switch to Indy instead of THttpClient to perform HTTP requests. Probably this will solve - or at least allow you to do so - the failed connections made from old OS.

The README is updated to show how to use Indy in the client:

https://github.com/landgraf-dev/openapi-delphi-generator#client-compatibility