0

On Windows 10, with a new Rails 7 application and an empty system test, when I run the system test:

rails test test/system/empty_test.rb, I got following error:

C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate) (OpenSSL::SSL::SSLError)

        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:46:in `ssl_socket_connect'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:1038:in `connect'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:970:in `do_start'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:959:in `start'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:621:in `start'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:496:in `get_response'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/network.rb:33:in `get_response'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/network.rb:14:in `get'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:66:in `latest_point_release'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:39:in `block in latest_version'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:166:in `with_cache'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:37:in `latest_version'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:122:in `download_version'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:134:in `correct_binary?'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:91:in `update'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:149:in `block in <main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/browser.rb:36:in `preload'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/driver.rb:27:in `initialize'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_test_case.rb:159:in `new'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_test_case.rb:159:in `driven_by'
        from G:/webshop/test/application_system_test_case.rb:4:in `<class:ApplicationSystemTestCase>'
        from G:/webshop/test/application_system_test_case.rb:3:in `<main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from G:/webshop/test/system/empty_test.rb:1:in `<main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `block in load_tests'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `each'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `load_tests'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:40:in `run'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/commands/test/test_command.rb:33:in `perform'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/command/base.rb:87:in `perform'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/command.rb:48:in `invoke'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/commands.rb:18:in `<main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from bin/rails:4:in `<main>'

I am not sure what certificate the code is looking for, it is just a new site and I locally access it from localhost:3000.

Here is the code for the empty system test:

require "application_system_test_case"

class EmptyTest < ApplicationSystemTestCase
end

I used the empty test just to make sure it is not the test code caused the error.

Here is my question:

  1. Which certificate the rails system test is looking for?
  2. How could I fix it?

1 Answers1

0

Rails document should document this in System Testing section.

When we have System Testing with the default setting:

driven_by :selenium, using: :chrome, screen_size: [1400, 1400]

A system environment variable SSL_CERT_FILE should be defined.

I followed the answer in this thread:

Getting SSL error in ruby on Windows

It started to work right away.