Configure WEBrick to use automatically generated self-signed SSL/HTTPS certificate

后端 未结 1 905
無奈伤痛
無奈伤痛 2021-01-01 22:19

I want to develop my Ruby on Rails application locally with SSL/HTTPS, but I\'m having trouble trying to setup a server to use SSL. The following are the things I\'ve alread

相关标签:
1条回答
  • 2021-01-01 23:05

    Okay, I figured out what was wrong, I should've paid closer attention to the instructions for HTTPS in WEBrick, this is the exact code from the example:

    require 'webrick'
    require 'webrick/https' # SEE THIS?
    
    cert_name = [
      %w[CN localhost],
    ]
    
    server = WEBrick::HTTPServer.new(:Port => 8000,
                                     :SSLEnable => true,
                                     :SSLCertName => cert_name)
    

    See that line that says require 'webrick/https'? I didn't have that in my original config. I didn't think that I'd need it.

    Once I added it, my script started serving over HTTPS, and I could finally connect to https://localhost:4430/robots.txt. <face-palm>

    0 讨论(0)
提交回复
热议问题