sniff http ssl connectionAre HTTPS URLs encrypted?What does “connection reset by peer” mean?How can I connect to Android with ADB over TCP?Amazon S3 - HTTPS/SSL - Is it possible?SSL certificate rejected trying to access GitHub over HTTPS behind firewallForce SSL/https using .htaccess and mod_rewriteSSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”Managing errors in golangWarning about SSL connection when connecting to MySQL database

Why are subdominants unstable?

How to innovate in OR

Patio gate not at right angle to the house

Why didn't Stark and Nebula use jump points with their ship to go back to Earth?

Word for giving preference to the oldest child

Why does the Rust compiler not optimize code assuming that two mutable references cannot alias?

What is my clock telling me to do?

If the Moon were impacted by a suitably sized meteor, how long would it take to impact the Earth?

Security measures that could plausibly last 150+ years?

Narset, Parter of Veils interaction with Matter Reshaper

What are the closest international airports in different countries?

Why are we moving in circles with a tandem kayak?

Why does one get the wrong value when printing counters together?

Embedded C - Most elegant way to insert a delay

Applications of pure mathematics in operations research

How do you deal with characters with multiple races?

Should students have access to past exams or an exam bank?

"DDoouubbllee ssppeeaakk!!"

When encrypting twice with two separate keys, can a single key decrypt both steps?

Should I intervene when a colleague in a different department makes students run laps as part of their grade?

Raindrops in Python

PCB design using code instead of clicking a mouse?

Why did some Apollo missions carry a grenade launcher?

Circle symbol compatible with square and triangle



sniff http ssl connection


Are HTTPS URLs encrypted?What does “connection reset by peer” mean?How can I connect to Android with ADB over TCP?Amazon S3 - HTTPS/SSL - Is it possible?SSL certificate rejected trying to access GitHub over HTTPS behind firewallForce SSL/https using .htaccess and mod_rewriteSSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”Managing errors in golangWarning about SSL connection when connecting to MySQL database






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















given that i own a net.Listener socket, how can i detect that an incoming connection is using ssl.



I work with below code which works fine to dispatch bt/http connections.



The code performs byte-to-byte comparison on the buffered conn, when nothing is found it defaults to the bt listener.



I want it to be able to dispatch ssl tls connections, ideally with sni support to perform host dispatching, if i m correct.



package server

import (
"bufio"
"bytes"
"log"
"net"
)

type SocketDispatcher struct
net.Listener
Dispatchers []*Dispatcher


func (l *SocketDispatcher) Accept() (net.Conn, error)
for
conn, err := l.Listener.Accept()
if err != nil
return nil, err

var r *bufio.Reader
r, conn = makePeekedConn(conn)
if d := l.Snif(r); d != nil
d.Handle(conn)
continue

return conn, err



func (l *SocketDispatcher) Snif(r *bufio.Reader) *Dispatcher
for _, d := range l.Dispatchers
if d.Snif(r)
return d


return nil


type Dispatcher struct
Snif func(r *bufio.Reader) bool
accepted chan net.Conn


func (d *Dispatcher) Handle(conn net.Conn) error
go func()
d.accepted <- conn
()
return nil


func (d *Dispatcher) Accept() (net.Conn, error)
conn := <-d.accepted
return conn, nil


func CatchAll() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return true
,
accepted: make(chan net.Conn),



func HTTPDispatcher() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return HTTPSnif(r)
,
accepted: make(chan net.Conn),



//HTTPSnif detects http requests
func HTTPSnif(t *bufio.Reader) bool
ms := []string"GET", "PUT", "HEAD", "POST", "PATCH", "OPTION", "DELETE"
longuest := 0
for _, m := range ms
if longuest < len(m)
longuest = len(m)



remains := [][]byte
for _, m := range ms
b := []byte(m + " ")
remains = append(remains, b)


for e := 1; e <= longuest; e++
p, err := t.Peek(e)
if err != nil
log.Println("peek", err)
return false

remains = filter(remains, p)
if len(remains) == 0
return false

if len(remains) == 1
return true



return true


func filter(remains [][]byte, cur []byte) [][]byte
rests := [][]byte
for _, r := range remains
return rests


func peekCompare(t *bufio.Reader, search []byte) bool
var p []byte
for i := 1; i <= len(search); i++
var err error
p, err = t.Peek(i)
if err != nil
return false

if !bytes.HasPrefix(search, p)
return false


return bytes.Equal(search, p)










share|improve this question



















  • 1





    The client hello that starts every TLS connection is fairly easy to recognize. The Illustrated TLS Connection is quite educational.

    – Peter
    Mar 26 at 21:56


















0















given that i own a net.Listener socket, how can i detect that an incoming connection is using ssl.



I work with below code which works fine to dispatch bt/http connections.



The code performs byte-to-byte comparison on the buffered conn, when nothing is found it defaults to the bt listener.



I want it to be able to dispatch ssl tls connections, ideally with sni support to perform host dispatching, if i m correct.



package server

import (
"bufio"
"bytes"
"log"
"net"
)

type SocketDispatcher struct
net.Listener
Dispatchers []*Dispatcher


func (l *SocketDispatcher) Accept() (net.Conn, error)
for
conn, err := l.Listener.Accept()
if err != nil
return nil, err

var r *bufio.Reader
r, conn = makePeekedConn(conn)
if d := l.Snif(r); d != nil
d.Handle(conn)
continue

return conn, err



func (l *SocketDispatcher) Snif(r *bufio.Reader) *Dispatcher
for _, d := range l.Dispatchers
if d.Snif(r)
return d


return nil


type Dispatcher struct
Snif func(r *bufio.Reader) bool
accepted chan net.Conn


func (d *Dispatcher) Handle(conn net.Conn) error
go func()
d.accepted <- conn
()
return nil


func (d *Dispatcher) Accept() (net.Conn, error)
conn := <-d.accepted
return conn, nil


func CatchAll() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return true
,
accepted: make(chan net.Conn),



func HTTPDispatcher() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return HTTPSnif(r)
,
accepted: make(chan net.Conn),



//HTTPSnif detects http requests
func HTTPSnif(t *bufio.Reader) bool
ms := []string"GET", "PUT", "HEAD", "POST", "PATCH", "OPTION", "DELETE"
longuest := 0
for _, m := range ms
if longuest < len(m)
longuest = len(m)



remains := [][]byte
for _, m := range ms
b := []byte(m + " ")
remains = append(remains, b)


for e := 1; e <= longuest; e++
p, err := t.Peek(e)
if err != nil
log.Println("peek", err)
return false

remains = filter(remains, p)
if len(remains) == 0
return false

if len(remains) == 1
return true



return true


func filter(remains [][]byte, cur []byte) [][]byte
rests := [][]byte
for _, r := range remains
return rests


func peekCompare(t *bufio.Reader, search []byte) bool
var p []byte
for i := 1; i <= len(search); i++
var err error
p, err = t.Peek(i)
if err != nil
return false

if !bytes.HasPrefix(search, p)
return false


return bytes.Equal(search, p)










share|improve this question



















  • 1





    The client hello that starts every TLS connection is fairly easy to recognize. The Illustrated TLS Connection is quite educational.

    – Peter
    Mar 26 at 21:56














0












0








0








given that i own a net.Listener socket, how can i detect that an incoming connection is using ssl.



I work with below code which works fine to dispatch bt/http connections.



The code performs byte-to-byte comparison on the buffered conn, when nothing is found it defaults to the bt listener.



I want it to be able to dispatch ssl tls connections, ideally with sni support to perform host dispatching, if i m correct.



package server

import (
"bufio"
"bytes"
"log"
"net"
)

type SocketDispatcher struct
net.Listener
Dispatchers []*Dispatcher


func (l *SocketDispatcher) Accept() (net.Conn, error)
for
conn, err := l.Listener.Accept()
if err != nil
return nil, err

var r *bufio.Reader
r, conn = makePeekedConn(conn)
if d := l.Snif(r); d != nil
d.Handle(conn)
continue

return conn, err



func (l *SocketDispatcher) Snif(r *bufio.Reader) *Dispatcher
for _, d := range l.Dispatchers
if d.Snif(r)
return d


return nil


type Dispatcher struct
Snif func(r *bufio.Reader) bool
accepted chan net.Conn


func (d *Dispatcher) Handle(conn net.Conn) error
go func()
d.accepted <- conn
()
return nil


func (d *Dispatcher) Accept() (net.Conn, error)
conn := <-d.accepted
return conn, nil


func CatchAll() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return true
,
accepted: make(chan net.Conn),



func HTTPDispatcher() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return HTTPSnif(r)
,
accepted: make(chan net.Conn),



//HTTPSnif detects http requests
func HTTPSnif(t *bufio.Reader) bool
ms := []string"GET", "PUT", "HEAD", "POST", "PATCH", "OPTION", "DELETE"
longuest := 0
for _, m := range ms
if longuest < len(m)
longuest = len(m)



remains := [][]byte
for _, m := range ms
b := []byte(m + " ")
remains = append(remains, b)


for e := 1; e <= longuest; e++
p, err := t.Peek(e)
if err != nil
log.Println("peek", err)
return false

remains = filter(remains, p)
if len(remains) == 0
return false

if len(remains) == 1
return true



return true


func filter(remains [][]byte, cur []byte) [][]byte
rests := [][]byte
for _, r := range remains
return rests


func peekCompare(t *bufio.Reader, search []byte) bool
var p []byte
for i := 1; i <= len(search); i++
var err error
p, err = t.Peek(i)
if err != nil
return false

if !bytes.HasPrefix(search, p)
return false


return bytes.Equal(search, p)










share|improve this question














given that i own a net.Listener socket, how can i detect that an incoming connection is using ssl.



I work with below code which works fine to dispatch bt/http connections.



The code performs byte-to-byte comparison on the buffered conn, when nothing is found it defaults to the bt listener.



I want it to be able to dispatch ssl tls connections, ideally with sni support to perform host dispatching, if i m correct.



package server

import (
"bufio"
"bytes"
"log"
"net"
)

type SocketDispatcher struct
net.Listener
Dispatchers []*Dispatcher


func (l *SocketDispatcher) Accept() (net.Conn, error)
for
conn, err := l.Listener.Accept()
if err != nil
return nil, err

var r *bufio.Reader
r, conn = makePeekedConn(conn)
if d := l.Snif(r); d != nil
d.Handle(conn)
continue

return conn, err



func (l *SocketDispatcher) Snif(r *bufio.Reader) *Dispatcher
for _, d := range l.Dispatchers
if d.Snif(r)
return d


return nil


type Dispatcher struct
Snif func(r *bufio.Reader) bool
accepted chan net.Conn


func (d *Dispatcher) Handle(conn net.Conn) error
go func()
d.accepted <- conn
()
return nil


func (d *Dispatcher) Accept() (net.Conn, error)
conn := <-d.accepted
return conn, nil


func CatchAll() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return true
,
accepted: make(chan net.Conn),



func HTTPDispatcher() *Dispatcher
return &Dispatcher
Snif: func(r *bufio.Reader) bool
return HTTPSnif(r)
,
accepted: make(chan net.Conn),



//HTTPSnif detects http requests
func HTTPSnif(t *bufio.Reader) bool
ms := []string"GET", "PUT", "HEAD", "POST", "PATCH", "OPTION", "DELETE"
longuest := 0
for _, m := range ms
if longuest < len(m)
longuest = len(m)



remains := [][]byte
for _, m := range ms
b := []byte(m + " ")
remains = append(remains, b)


for e := 1; e <= longuest; e++
p, err := t.Peek(e)
if err != nil
log.Println("peek", err)
return false

remains = filter(remains, p)
if len(remains) == 0
return false

if len(remains) == 1
return true



return true


func filter(remains [][]byte, cur []byte) [][]byte
rests := [][]byte
for _, r := range remains
return rests


func peekCompare(t *bufio.Reader, search []byte) bool
var p []byte
for i := 1; i <= len(search); i++
var err error
p, err = t.Peek(i)
if err != nil
return false

if !bytes.HasPrefix(search, p)
return false


return bytes.Equal(search, p)







ssl go tcp






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 21:17









mh-cbonmh-cbon

2,9751 gold badge12 silver badges34 bronze badges




2,9751 gold badge12 silver badges34 bronze badges










  • 1





    The client hello that starts every TLS connection is fairly easy to recognize. The Illustrated TLS Connection is quite educational.

    – Peter
    Mar 26 at 21:56













  • 1





    The client hello that starts every TLS connection is fairly easy to recognize. The Illustrated TLS Connection is quite educational.

    – Peter
    Mar 26 at 21:56








1




1





The client hello that starts every TLS connection is fairly easy to recognize. The Illustrated TLS Connection is quite educational.

– Peter
Mar 26 at 21:56






The client hello that starts every TLS connection is fairly easy to recognize. The Illustrated TLS Connection is quite educational.

– Peter
Mar 26 at 21:56













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366317%2fsniff-http-ssl-connection%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366317%2fsniff-http-ssl-connection%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript