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 8706081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:31:35+00:00 2026-06-13T03:31:35+00:00

I need to establish a TCP connection with my server which has a SSL

  • 0

I need to establish a TCP connection with my server which has a SSL enabled port, that I need to access.

I need to send a XML file and get the response from the server.

Before the SSL was enabled, I was able to get the data from the server using the below mentioned code.

require 'socket'
myXML = 'test_xml' 
host = 'myhost.com'   
port = 12482               

socket = TCPSocket.open(host,port)  # Connect to server  
socket.send(myXML, 0)
response = socket.recvfrom(port)
puts response
socket.close

Now I have a ‘certi.pfx’ with which I need to establish a connection, Send my_xml data and get the response. How can this be done.

I would also like to know if I have the ‘pem’ and ‘key’ file, how can I establish a connection, Send my_xml data and get the response.

Please help.

  • 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-13T03:31:36+00:00Added an answer on June 13, 2026 at 3:31 am
    require 'socket'
    require 'openssl'
    
    myXML = 'my_sample_data'
    host = 'my_host.com'
    port = my_port                
    
    socket = TCPSocket.open(host,port)
    ssl_context = OpenSSL::SSL::SSLContext.new()
    ssl_context.cert = OpenSSL::X509::Certificate.new(File.open("certificate.crt"))
    ssl_context.key = OpenSSL::PKey::RSA.new(File.open("certificate.key"))
    ssl_context.ssl_version = :SSLv23
    ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)
    ssl_socket.sync_close = true
    ssl_socket.connect
    
    ssl_socket.puts(myXML)
    while line = ssl_socket.gets
      p line
    end
    ssl_socket.close
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to establish a Socket connection (TCP) between two hosts (say host1 and
I need to establish the Connection with MailServer (Custom Mail server). Whenever I tried
I need to establish a P2P UDP and TCP Connection between two Users. Both
I have written a TCP server implementation using which I created an application which
I need to keep a TCP connection established indefinitely (as far as possible). Is
I need to implement tcp socket communication between server and iOS client. I am
My iPhone application establishes a TCP connection through wifi to a remote server. However,
I have Chat Client Server Application, which we are scaling up. so I need
I need to establish two channels between client and server, first is a UDP
I need to establish socket connection between window machine and iPads. So here window

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.