Skip to content

Commit b0ca389

Browse files
MagicalTuxclaude
andcommitted
Add -insecure flag to restupload CLI tool
Allow users to skip TLS certificate verification for self-signed or invalid certificates by using the -insecure flag. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a07f555 commit b0ca389

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

cli/restupload/main.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"crypto/tls"
56
"encoding/json"
67
"flag"
78
"fmt"
@@ -57,6 +58,7 @@ var (
5758
hostname = flag.String("hostname", "", "override API hostname (e.g., api.example.com)")
5859
method = flag.String("method", "POST", "HTTP method for the initial API request")
5960
cookies = flag.String("cookies", "", "cookies to send with the request (format: name1=value1; name2=value2)")
61+
insecure = flag.Bool("insecure", false, "allow insecure SSL connections (skip certificate verification)")
6062
)
6163

6264
func main() {
@@ -81,6 +83,36 @@ func main() {
8183

8284
args := flag.Args()
8385

86+
// Configure insecure transport if requested
87+
if *insecure {
88+
// Create a new transport based on the default one but with TLS verification disabled
89+
insecureTransport := &http.Transport{
90+
Proxy: http.ProxyFromEnvironment,
91+
MaxIdleConns: 100,
92+
MaxIdleConnsPerHost: 50,
93+
MaxConnsPerHost: 200,
94+
IdleConnTimeout: 90 * time.Second,
95+
ResponseHeaderTimeout: 90 * time.Second,
96+
TLSHandshakeTimeout: 10 * time.Second,
97+
ExpectContinueTimeout: 5 * time.Second,
98+
TLSClientConfig: &tls.Config{
99+
InsecureSkipVerify: true,
100+
},
101+
}
102+
103+
// Replace the global HTTP clients with insecure versions
104+
rest.RestHttpClient = &http.Client{
105+
Transport: insecureTransport,
106+
Timeout: 300 * time.Second,
107+
}
108+
rest.UploadHttpClient = &http.Client{
109+
Transport: insecureTransport,
110+
Timeout: time.Hour,
111+
}
112+
113+
log.Println("WARNING: TLS certificate verification disabled")
114+
}
115+
84116
// Prepare context with hostname override if provided
85117
ctx := context.Background()
86118
if *hostname != "" {

0 commit comments

Comments
 (0)