Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:14:41+00:00 2026-06-05T22:14:41+00:00

How do you secure a socket with SSL in Ruby when you need to

  • 0

How do you secure a socket with SSL in Ruby when you need to communicate over plaintext first?

I can’t use OpenSSL::SSL::SSLServer because it’s the client’s responsibility to request an SSL connection first

To put a long story short, I am attempting to implement RFC3207, where the client sends the keyword “STARTTLS”, and then an SSL connection is created.

My question is “How do I create the SSL connection after the server has sent ‘220 OK’?”

I know I can use OpenSSL::SSL::SSLSocket on the client-side, but I have no idea what to do on the server-side

If you know how to do this in a language other than Ruby, just post the code and I’ll translate it, I’ve been working on this for about 8 hours and I need everything I can get

I have asked in #ruby-lang, but with no avail, and I have tried wrapping Socket objects in SSLSockets on the server and client at the same time, but that isn’t working either

In short, I’m very stuck, I need all the help I can get

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:14:44+00:00Added an answer on June 5, 2026 at 10:14 pm

    I created this gist to illustrate how to set up a minimal TLS server. You may want to leave out lines 62-67, that was to illustrate a new feature on trunk.

    But other than that, it’s a fully working TLS server, you may build on it to add further functionality.

    You may also want to change the server certificate’s CN from “localhost” to a real domain if you want to use it seriously 🙂

    You may notice that the largest part of the work is actually setting up the PKI aspects correctly. The core server part is this:

    ctx = OpenSSL::SSL::SSLContext.new
    ctx.cert = ... # the server certificate
    ctx.key = ... # the key associated with this certificate
    ctx.ssl_version = :SSLv23
    tcps = TCPServer.new('127.0.0.1', 8443)
    ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
    ssls.start_immediately = true
    begin
      loop do
        ssl = ssls.accept
        puts "Connected"
        begin
          while line = ssl.gets
            puts "Client says: #{line}"
            ssl.write(line) # simple echo, do something more useful here
          end
        ensure
          ssl.close
        end
      end
    ensure
      tcps.close if tcps
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When we use SSL(Secured Socket Level) Server has private key whereas client has public
I am trying to use OpenSSL in my application, and achieve a secure connection.
I'm in the process of converting my non secure socket to ssl, using boost::asio::ssl
How secure is SSL (Secure Socket Layer)? As in, how much will it take
I have a trivial secure socket server-client program. For the server certificates, I created
I'm trying to secure a connection from a Java Client/Server application that communicates over
I need to implement tcp socket communication between server and iOS client. I am
Is there a secure Python intepreter? Imagine a Python VM you can run on
I need to secure my website without using the ASP.NET built in login controls
I am trying to secure communications via SSL/TLS for one of our Web Service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.