Skip to content

SSL handshake failure while connecting to OpenAI API server using Brave browser #52

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

Closed
xshapira opened this issue Apr 1, 2023 · 14 comments

Comments

@xshapira
Copy link

xshapira commented Apr 1, 2023

It seems there’s an SSL handshake failure while attempting to establish a secure connection with the OpenAI API server.

When running the following command:

aishell 'print Hello World'

I'm getting this error:

SSLError: HTTPSConnectionPool(host='explorer.api.openai.com', port=443): Max retries
exceeded with url: /api/auth/session (Caused by SSLError(SSLError(1, '[SSL:
SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:992)')))

Are there any specific Brave browser settings that could be causing this issue?

@code-yeongyu
Copy link
Owner

Guess the problem of revChatGPT? have you tried with the openai official api or the reverse engineered api?

Sorry for the late answer BTW

@luxkatana
Copy link

having the same issue! I am using the reverse engineering one.

Browser: Firefox
SSLError: HTTPSConnectionPool(host='explorer.api.openai.com', port=443): Max retries exceeded with url: /api/auth/session (Caused by SSLError(SSLError(1, '[SSL:
SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:992)')))

@code-yeongyu
Copy link
Owner

code-yeongyu commented Apr 10, 2023

Currently recommend to use Official API, but i am looking into this and will fix ASAP. sorry 😞

@code-yeongyu code-yeongyu pinned this issue Apr 11, 2023
@code-yeongyu
Copy link
Owner

code-yeongyu commented Apr 11, 2023

  1. The cookie parsing feature retrieves the 'session token` from the given browser.
  2. The session token no longer works as OpenAI's ChatGPT authentication method
  3. access token now works instead of session token
  4. Since access token can be expired easily, I think I have to add an option to the AiShell Config: default browser and to retrieve access token, every time the user queries.

@code-yeongyu
Copy link
Owner

code-yeongyu commented Apr 11, 2023

I am super busy now so expecting to be fixed not very soon, so now just recommend to use Official API. 😓 Thanks!

@code-yeongyu
Copy link
Owner

code-yeongyu commented Apr 11, 2023

As a solution of this, I am thinking of:

  1. Update config json like following
{
  "language_model": "reverse_engineered_chatgpt",
  "openai_api_key": null,
  "browser": "brave" // firefox, chrome, safari or whatever
}
  1. Replace session token retrieving code as access token retrieving code
  • Using the browser's cookie, send request to https://chat.openai.com/api/auth/session to get the access token
  1. Send request to ChatGPT using configured information from 2

@xshapira
Copy link
Author

As a solution of this, I am thinking of:

  1. Update config json like following
{
  "language_model": "reverse_engineered_chatgpt",
  "openai_api_key": null,
  "browser": "brave" // firefox, chrome, safari or whatever
}
  1. Replace session token retrieving code as access token retrieving code
  • Using the browser's cookie, send request to https://chat.openai.com/api/auth/session to get the access token
  1. Send request to ChatGPT using configured information from 2

This looks good! Reverse engineering is really useful for ChatGPT Plus subscribers. Do you know when you'll release an update?

Thanks for the hard work 👍

@code-yeongyu
Copy link
Owner

I am guessing within a week! 👍 Thank you 🙌

@code-yeongyu
Copy link
Owner

@xshapira FYI, before I update, You can use aishell by doing following:

  1. You can visit https://chat.openai.com/api/auth/session to get the access token
  2. and manually set access token into the json file (~/.aishell_config.json)

@xshapira
Copy link
Author

@xshapira FYI, before I update, You can use aishell by doing following:

  1. You can visit https://chat.openai.com/api/auth/session to get the access token
  2. and manually set access token into the json file (~/.aishell_config.json)

I followed your instructions but got this error (have the same issue with the younger brother of this project, YGK-a):

Screen Shot 1

@code-yeongyu
Copy link
Owner

code-yeongyu commented Apr 11, 2023

it definetely looks like because of the version of revchatgpt, i am going to bump up that.

@code-yeongyu
Copy link
Owner

code-yeongyu commented Apr 11, 2023

Just released new version with version up. Guess now it's gonna work.

Plus, if you have further issues with YGK-a, please issue it on YGK-a. Thanks!

@xshapira
Copy link
Author

Just released new version with version up. Guess now it's gonna work.

Plus, if you have further issues with YGK-a, please issue it on YGK-a. Thanks!

Works like a charm! Thank you 👍

@code-yeongyu
Copy link
Owner

code-yeongyu commented Apr 15, 2023

Hey @xshapira! I've just released a new version featuring automatic browser login using access tokens! #56

Now, every time you make a request, it retrieves a fresh access token using your credentials from your chosen browser. Although this is a breaking change, you'll need to set up AiShell once more, but it shouldn't be too bothersome as all you need to do is select your preferred browser. And this patch also have done to ygka too. (They now share the same config)

Thank you for using the AiShell!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants