Skip to content

Commit

Permalink
Add support for flexible TLS configuration (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper-elimity authored Mar 2, 2023
1 parent c0df2c2 commit f761211
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.13'
- uses: golangci/golangci-lint-action@v2
- uses: golangci/golangci-lint-action@v3
with:
version: v1.35
version: v1.47.3
- run: go test -v

on: pull_request
5 changes: 4 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ issues:
linters:
enable:
- goimports
- golint
- revive

run:
deadline: 5m
8 changes: 7 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ func NewClient(basePath, token string, sourceID int) (Client, error) {
//
// The resulting client does not verify the TLS certificate of the configured server.
func NewClientDisableTLSCertificateVerification(basePath, token string, sourceID int) Client {
config := &tls.Config{InsecureSkipVerify: true}
return NewClientWithTLSConfig(basePath, token, config, sourceID)
}

// NewClientWithTLSConfig creates a new client that uses the given TLS configuration.
func NewClientWithTLSConfig(basePath, token string, config *tls.Config, sourceID int) Client {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
transport.TLSClientConfig = config
client := &http.Client{Transport: transport}
return Client{
basePath: basePath,
Expand Down

0 comments on commit f761211

Please sign in to comment.