Skip to content

Commit

Permalink
Merge pull request #1860 from projectdiscovery/issue-1858-fix-ztls-ct…
Browse files Browse the repository at this point in the history
…x-err

fix `ztls` context deadline error
  • Loading branch information
Mzack9999 committed Aug 12, 2024
2 parents 5ff7236 + 493e493 commit f07cf4c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion common/httpx/tls.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package httpx

import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
Expand Down Expand Up @@ -62,7 +63,9 @@ func (h *HTTPX) ZTLSGrab(r *http.Response) *clients.Response {
}
// canonical net concatenation
host = net.JoinHostPort(hostname, fmt.Sprint(port))
tlsConn, err := h.Dialer.DialTLS(r.Request.Context(), "tcp", host)
ctx, cancel := context.WithTimeout(context.Background(), h.Options.Timeout)
defer cancel()
tlsConn, err := h.Dialer.DialTLS(ctx, "tcp", host)
if err != nil {
return nil
}
Expand Down Expand Up @@ -106,6 +109,7 @@ func convertCertificateToResponse(hostname string, cert *x509.Certificate) *clie
SHA1: clients.SHA1Fingerprint(cert.Raw),
SHA256: clients.SHA256Fingerprint(cert.Raw),
},
Serial: clients.FormatToSerialNumber(cert.SerialNumber),
}
response.IssuerDN = clients.ParseASN1DNSequenceWithZpkixOrDefault(cert.RawIssuer, cert.Issuer.String())
response.SubjectDN = clients.ParseASN1DNSequenceWithZpkixOrDefault(cert.RawSubject, cert.Subject.String())
Expand Down

0 comments on commit f07cf4c

Please sign in to comment.