title: Ruby MITM proxy
body: <p>I'm searching for some examples on how to write a proxy in Ruby that supports HTTPS. I have a simple proxy implemented with Webricks HTTPProxyServer, but I noticed, that HTTPS traffic is just tunneling (as it should ;) ). But I want to record the content with VCR (regarding my question here <a href="https://stackoverflow.com/questions/13039251/record-phantomjs-ajax-calls-with-vcr-inside-capybara">VCRProxy: Record PhantomJS ajax calls with VCR inside Capybara</a>) and as long the content is only tunnled through, VCR can't record it.</p>
  
  <p>So I was thinking of writing the proxy as a man-in-the-middle, generate SSL certificates on the fly (I don't care about certificate errors, its just for testing), and then I would be able to record the content / playback it later.</p>
  
  <p>So if somebody has a good ressource from how to start, or a tutorial or a gist, please let me know.</p>
  
  <p>PS: I have already seen this questions, but they don't provide any further stuff (and it need to be in ruby):</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/8129260/man-in-the-middle-mitm-proxy-with-https-support">Man in the Middle (MITM) proxy with HTTPS support</a></li>
  <li><a href="https://stackoverflow.com/questions/12187509/how-do-i-write-a-simple-https-proxy-server-in-ruby">How do I write a simple HTTPS proxy server in Ruby?</a></li>
  <li><a href="https://stackoverflow.com/questions/2679104/help-with-http-intercepting-proxy-in-ruby">Help with HTTP Intercepting Proxy in Ruby?</a></li>
  </ul>