oesmith / puffing-billy

A rewriting web proxy for testing interactions between your browser and external sites. Works with ruby + rspec.
MIT License
654 stars 170 forks source link

Puffing Billy Receiving Requests but not Responses from Firefox #312

Closed Judimax closed 3 years ago

Judimax commented 3 years ago

Puffing Billy Receiving Requests but not Responses from Firefox

Expected Behavior

the browser should allow for the insecure cert coming from puffing billy to proxy the request

Current Behavior

140326415501056:error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca:../ssl/record/rec_layer_s3.c:1543:SSL alert number 48

Possible Solution

no clue I see theres a --proxy-bypass-list option for the chrome browser but no similar solution in firefox

Steps to Reproduce

issue

Environment

property value data
OS Windows 10 Pro
Browser Version Mozilla Firefox 90.0 (20210705185941)
Ruby v 3.0.0
Capybara 3.35.3
Selenium-webdriver 3.142.7
Puffing Billy 2.4.1

Files

FILE e2e.rb

# works for chrome in a previous report
Capybara.register_driver :chrome_billy do |app|

  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument %{--ignore-certificate-errors}
  options.add_argument %{--proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}}
  options.add_argument " --proxy-bypass-list=<-loopback>" # New argument here to ensure requests to localhost are sent to Puffing Billy's proxy

    Capybara::Selenium::Driver.new(
        app,
        :browser => :chrome,
    :options => options,
    :clear_local_storage => true,
    :clear_session_storage => true
    )
end
#

# doesnt work for firefox
Capybara.register_driver :firefox_billy do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new %{firefox/profiles/capybara}
  profile.assume_untrusted_certificate_issuer = false
  profile.proxy = Selenium::WebDriver::Proxy.new(
    http: "#{Billy.proxy.host}:#{Billy.proxy.port}",
    ssl: "#{Billy.proxy.host}:#{Billy.proxy.port}")
  PP.pp profile

  options  =  Selenium::WebDriver::Firefox::Options.new(:profile => profile)
  capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(:accept_insecure_certs => true)
  Capybara::Selenium::Driver.new(
    app,
    options: options,
    desired_capabilities: capabilities
  )

end

# ...
RSpec.feature %{staging} do

    scenario %{check that puffing billy is working}  do
      my_proc = Proc.new do |*args|
        response = Billy.pass_request(*args)

        PP.pp response # we should be getting responses here
      end
      proxy.stub('http://localhost:4521/').and_return(my_proc)
      sleep 10
      # PP.pp Billy.proxy.requests
    end
end 

Detailed Description

Possible Implementation

reconfigure the drivers in the ruby gem to accept the insecure certs and bypass localhost proxy, getting it to work

issue Gemfile.txt