Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL certification error #51

Closed
asnagni opened this issue Mar 16, 2024 · 5 comments
Closed

SSL certification error #51

asnagni opened this issue Mar 16, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@asnagni
Copy link

asnagni commented Mar 16, 2024

Describe the bug

Hello guys,
First of all I would like to say thank you for this work and providing to the community this c++ Library 👍.
I was on OpenAI API website looking for a C++ option and I came across your library. I was able to easily build it and integrate it into our project without any issue (Android & iOS). Our code is C++ based - obviously 😊.
To make the learning curve simple, I just took your “conversasion” example and used it without any modification. Just to make sure that everything is working fine. Unfortunatunatly the “ChatCompletion” call is failling. This is the error/exception message that I have:
liboai::netimpl::Session::Perform(): Peer certificate cannot be authenticated with given CA certificates (E_CURLERROR:0x06)

Based on your examples/tutorials I’m not seeing anywhere where you need to:
1) provide a certificate file. If this is needed and it omitted in the example could please tell which Api call to use. 

2) or the need to turn of the SSL verification - to do something like this:
	curl_ = curl_easy_init();
	curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYPEER, 0L);


Would you know how to fix this issue?

Thank you,
Stay safe

To Reproduce

  1. Build current version for your iOS or Android project. There is nothing special if your have Curl & Json
  2. Use the conversation code/example to test

Code snippets

liboai::OpenAI oai;
        
        // create a conversation
        liboai::Conversation convo;

        // add a message to the conversation
        convo.AddUserData("Hello, how are you?");

        if (oai.auth.SetKey(m_openaiApiKey))
        {
            try
            {
                liboai::Response response = oai.ChatCompletion->create( "gpt-3.5-turbo", convo );

                // update our conversation with the response
                convo.Update(response);
            
                // print the response
                std::cout << convo.GetLastResponse() << std::endl;
            }
            catch (std::exception& e)
            {
                std::cout << e.what() << std::endl;
            }
        }

OS

iOS

Library version

liboai v3.2.1

@asnagni asnagni added the bug Something isn't working label Mar 16, 2024
@asnagni
Copy link
Author

asnagni commented Mar 16, 2024

Hi guys,
I have an additional information. I downloaded the single header file library "openai-cpp" and it is working. I don't have the ssl certificate issue. Which may indicate that the issue is with liboai.
I have and additional information that may help find the issue, I'm using curl-8.1.2

Thank you,
Stay safe

@D7EAD
Copy link
Owner

D7EAD commented Mar 31, 2024

Hi,

Sorry for the late response.

In liboai's core network back-end source code, I do not force the library to verify certificate of peers. The default for this setting, according to cURL, is enabled - so peer certificates will be verified (see here).

I can easily add an option to enable or disable this, and this will fix your issue. I can easily do this in due time, and once done, I will update here.

Best.

@asnagni
Copy link
Author

asnagni commented Mar 31, 2024 via email

@D7EAD
Copy link
Owner

D7EAD commented Apr 1, 2024

Hi,

I have released a quick-fix PR (#52) for this issue. Please update the file changed and use the new pre-processor definition described in the PR, as well as the debug pre-processor definition LIBOAI_DEBUG to ensure the peer verification is being disabled on your end (see line 2 in the terminal output below).

image

Let me know the results and, if successful, I will push to main branch.

Best.

@D7EAD D7EAD closed this as completed Apr 11, 2024
@asnagni
Copy link
Author

asnagni commented May 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants