Support Corporate HTTPS Inspection

Created on 28 November 2023, about 1 year ago
Updated 29 November 2023, about 1 year ago

Problem/Motivation

When attempting to use this module behind a corporate firewall that does HTTPS inspection, I get a CURL error originating from the openapi-php library I think. I am using DDEV and it uses mkcert to I think pass self signed certs into my DDEV/WSL environment and Drupal properly handles the HTTPS inspection, so I am just wondering if something can be done to help other like me not hit this issue? Some how pass some settings from Drupal along to OpenAI-PHP client?

Steps to reproduce

1. Be behind a corporate Firewall doing HTTPS inspection with self signed certs.
2. Local Development environment such as DDEV
3. Enable openai core and prompt explorer modules with API key Configured.
4. Visit /admin/config/openai/openai-prompt
5. See following Error

The website encountered an unexpected error. Please try again later.

OpenAI\Exceptions\TransporterException: cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.openai.com/v1/models in OpenAI\Transporters\HttpTransporter->sendRequest() (line 108 of /var/www/html/vendor/openai-php/client/src/Transporters/HttpTransporter.php).
GuzzleHttp\Handler\CurlFactory::finishError(Object, Object, Object) (Line: 110)
GuzzleHttp\Handler\CurlFactory::finish(Object, Object, Object) (Line: 47)
GuzzleHttp\Handler\CurlHandler->__invoke(Object, Array) (Line: 28)
GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 48)
GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object, Array) (Line: 35)
GuzzleHttp\PrepareBodyMiddleware->__invoke(Object, Array) (Line: 31)
GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 55)
GuzzleHttp\RedirectMiddleware->__invoke(Object, Array) (Line: 63)
GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object, Array) (Line: 75)
GuzzleHttp\HandlerStack->__invoke(Object, Array) (Line: 333)
GuzzleHttp\Client->transfer(Object, Array) (Line: 107)
GuzzleHttp\Client->sendAsync(Object, Array) (Line: 138)
GuzzleHttp\Client->sendRequest(Object) (Line: 49)
OpenAI\Transporters\HttpTransporter->OpenAI\Transporters\{closure}() (Line: 102)
OpenAI\Transporters\HttpTransporter->sendRequest(Object) (Line: 49)
OpenAI\Transporters\HttpTransporter->requestObject(Object) (Line: 28)
OpenAI\Resources\Models->list() (Line: 86)
Drupal\openai\OpenAIApi->getModels() (Line: 130)
Drupal\openai\OpenAIApi->filterModels(Array) (Line: 51)
Drupal\openai_prompt\Form\PromptForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('openai_prompt_prompt', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

I am a bit fuzzy as to how Drupal does not have a problem with HTTPS inspection, but I did find these issues with the OpenAI-PHP library that could be related to how to configure it to work correctly?
https://github.com/openai-php/client/issues/263
https://github.com/openai-php/client/issues/12

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States NicholasS

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024