DeepLcom / deepl-php

Official PHP library for the DeepL language translation API.
MIT License
207 stars 22 forks source link

Adding curl-options #14

Closed knallcharge closed 1 year ago

knallcharge commented 2 years ago

Hi, is there a way to add curl-options when instantiating the Translator? I need to include verify_peer: false and verify_host: false, otherwise I'll get a "SSL certificate error: unable to get local issuer certificate"-exception.

I have tried $translator = new \DeepL\Translator('KEY', ['headers' => ['verify_peer' => false, 'verify_host' => false]]); but that doesn't work (same with "0" instead of "false" for both options). I see the options getting added to $curlOptions in HttpClient (line 182), but they don't seem to do anything.

Thanks

daniel-jones-deepl commented 1 year ago

Hi @Knallcharge, thanks for creating this issue. No, currently the library does not allow configuring the cURL options.

There might be a better way to resolve your problem, by fixing your SSL certificate set up, as described in the StackOverflow answers here. Disabling SSL verification exposes you to security vulnerabilities, so it is best avoided.

That said, yes we can add this functionality in future.

knallcharge commented 1 year ago

Hi @daniel-jones-deepl thanks for getting back! I'm aware of the security issues this causes, but unfortunately my setup is in a company network where I can't resolve the certificate as described in the post you mentioned (tried all that) as a special security software intercepts https-traffic to check it before re-encrypting it with its own certificate. So I could live with the security issues as this is only for development, on the prod-servers we have a different setup and the library works as expected. So if this could be added some time, I'd be glad.

JanEbbing commented 1 year ago

Hi @Knallcharge , does the new feature to specify a custom HTTP client accomodate your use case? Im afraid to specify cURL options you will need to use a PSR-18 wrapper for cURL, but with that it should work. I provided an example how to use the new option in the README.

knallcharge commented 1 year ago

Hi @JanEbbing, thanks for the hint. Just tried it (using Symfony's Psr18Client) and it works! I'll still have to do some tests in a different environment, but this should be resolved. Thanks again, closing this.