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

SSLERROR occurred when running http method in the executable file: certificate verify failed. #749

Closed
Vucius opened this issue Apr 22, 2023 · 1 comment

Comments

@Vucius
Copy link

Vucius commented Apr 22, 2023

I was able to run my GUI program normally under RubyMine. Here is the test code:

require 'http'
require 'glimmer-dsl-libui'
require 'json'

class MyWindow
  include Glimmer

  def initialize
    @main_window = window('Hello, World!', 300, 200) {
      horizontal_box {
        @label = label('Hello, Glimmer DSL for LibUI!')
        button('Click me!') {
          on_clicked do
            sss = returnstr
            msg_box('Hello', sss)
          end
        }
      }

      on_closing do
        puts 'Closing window...'
      end
    }
  end

  def show
    @main_window.show
  end
end

def returnstr
  ccoo = 'my_cookie'
  aim_url = 'https://leetcode.com/graphql/'
  submissionlist_data_query =
    {
      "query": "\n    query submissionList($offset: Int!, $limit: Int!, $lastKey: String, $questionSlug: String!, $lang: Int, $status: Int) {\n  questionSubmissionList(\n    offset: $offset\n    limit: $limit\n    lastKey: $lastKey\n    questionSlug: $questionSlug\n    lang: $lang\n    status: $status\n  ) {\n    lastKey\n    hasNext\n    submissions {\n      id\n      title\n      titleSlug\n      status\n      statusDisplay\n      lang\n      langName\n      runtime\n      timestamp\n      url\n      isPending\n      memory\n      hasNotes\n    }\n  }\n}\n    ",
      "variables": {
        "questionSlug": 'two-sum',
        "offset": 0,
        "limit": 20,
        "lastKey": nil
      },
      "operationName": "submissionList"
    }
  submissionlist_data_header = {
    'content-type' => 'application/json',
    'Cookie' => ccoo
  }
  #ctx = OpenSSL::SSL::SSLContext.new
  #ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
  #submissionlist_data = HTTP.post(URI(aim_url), :body => submissionlist_data_query.to_json, :headers => submissionlist_data_header, :ssl_context => ctx)
submissionlist_data = HTTP.post(URI(aim_url), :body => submissionlist_data_query.to_json, :headers => submissionlist_data_header
  p submissionlist_data.code
  submissionlist_data_json = JSON.load(submissionlist_data.body)
  p submissionlist_data_json
  #submissionlist_data_json["data"]["questionSubmissionList"]["submissions"]
  "fuck"
end

my_window = MyWindow.new
my_window.show

However, when I used ocra to package the .rb file into an .exe and ran the .exe, the program crashed.

After disabling certificate verification and repackaging the .exe, the program ran normally.

Although the problem was solved, I am still confused about whether it is an issue with httprb or ocra. I did not continue to investigate and just wanted to share this information here.

@tarcieri
Copy link
Member

Certificate verification is handled by Ruby/OpenSSL, at a layer much lower than http.rb.

It sounds like there is something wrong with the certificates in the system truststore.

@tarcieri tarcieri closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2023
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

2 participants