Skip to content

Commit

Permalink
feat: crypto/tlsutil: add cmd/httpsversioncheck
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Nov 10, 2024
1 parent 4d3620c commit 01cf1ac
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crypto/tlsutil/cmd/httpsversioncheck/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"context"
"crypto/tls"
"fmt"
"os"

"github.com/grokify/mogo/crypto/tlsutil"
)

func main() {
url := "https://pkg.go.dev/"
if len(os.Args) > 1 {
url = os.Args[1]
}

fmt.Printf("Checking URL: [%s]\n", url)

// Test each TLS version
tlsVersions := []tlsutil.TLSVersion{
tls.VersionTLS10,
tls.VersionTLS11,
tls.VersionTLS12,
tls.VersionTLS13}

for _, tlsVersion := range tlsVersions {
err := tlsutil.SupportsTLSVersion(context.Background(), tlsVersion, url)
if err != nil {
fmt.Printf("%s: Not Supported: (%s)\n", tlsVersion.String(), err.Error())
} else {
fmt.Printf("%s: Supported\n", tlsVersion.String())
}
}
}

0 comments on commit 01cf1ac

Please sign in to comment.