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

  • Home
  • SEARCH
  • 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 8476365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:09:29+00:00 2026-06-10T18:09:29+00:00

I need to connect client & server over untrusted network. I’ve considered using TLS

  • 0

I need to connect client & server over untrusted network. I’ve considered using TLS (crypto/tls), but from what I understand, I first need to create a create a crypto/x509.Certificate. But I feel overwhelmed by all the parameters I need to pass to the x509.CreateCertificate() function – it says it needs all of the following fields:

SerialNumber, Subject, NotBefore, NotAfter, KeyUsage, BasicConstraintsValid, IsCA, MaxPathLen, SubjectKeyId, DNSNames, PermittedDNSDomainsCritical, PermittedDNSDomains.

I have full control over both endpoints, so I believe I don’t need any expiration or invalidation support/parameters (I can change keys both on client and server at any time I want) – so I can probably skip NotBefore and NotAfter (? or do I have to set them anyway?). What should I put in all the other fields, and why, to avoid any vulnerabilities? Also, can I use the same private/public key pair for both ways authentication (client to server, and server to client), or do I have to use 2 pairs?

Or, is there something simpler than TLS that I could use? Note however, that I need to two way authentication.

EDIT:

I created a simple library based on suggestions from the accepted answer, plus key generation code from generate_cert.go – see:

github.com/akavel/tunnel

  • 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-10T18:09:30+00:00Added an answer on June 10, 2026 at 6:09 pm

    Owlstead is partly correct. Your best bet is creating self signed certificates using OpenSSL. However, I would then use the Go TLS library for encryption. Below is some code that may help you.

    Creating an x509 key pair

    I normally follow the instructions here. Summary of commands (do for both client and server):

    openssl genrsa -des3 -out server.key 1024
    openssl req -new -key server.key -out server.csr
    cp server.key server.key.org
    openssl rsa -in server.key.org -out server.key
    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
    

    Using Go’s TLS library

    First, create a tls.Config. One TLS config will work on both client and server but some of the options only need to be set on one or the other:

    cert, err := tls.LoadX509KeyPair(cert, key)
    config := &tls.Config{
        Certificates: []Certificates{cert},
        ClientAuth: tls.RequireAnyClientCert, // Must be done on server
        InsecureSkipVerify: true, // Must be done on client
    }
    

    On the server, you need to setup a TLS listener. This sets it up on port 4443:

    listener, err := tls.Listen("tcp", ":4443", config)
    for {
        conn, err := listener.Accept()
        acceptConn(conn) // your code
    }
    

    On the client:

    conn, err := tls.Dial("tcp", serverAddr, config)
    

    This will create an encrypted connection, but it will not verify the other side is who they say they are. The easiest way to do that is to give each server the public key of the other server and compare it to the server that has just connected. To find the public key on the other server, you need to:

    c := conn.(*tls.Conn) // convert net.Conn from listener to tls conn
    err := c.Handshake() // ensure handshake is completed without error
    state := c.ConnectionState()
    pubKey, err := x509.MarshalPKIXPublicKey(state.PeerCertificates[0])
    bytes.Equal(pubKey, knownKey) // compare to known value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We need to implement client / server to open / edit Office documents from
I have JAX-WS generate client proxys that need to connect using HTTPS. The certificate
I need to connect two android devices using wifi. One device is a server,
I need to obtain UDP datagram from Asynchronous Socket Server but an exception occurred
Hi, I'm trying to connect my chat client to my server, but I keep
I need to connect to Oracle9,10 and 11 in my java application.The client will
I need my client to bind to a particular port and then connect to
I need connect to server git. http://help.github.com/win-set-up-git/ I do everything to the point, 4
I need to connect to a MongoDB instance from my EJB3 application, running on
i need to connect to another server we manage and have it's results (in

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.