Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,26 @@ func (client *Client) SetDSN(dsn string) error {
return nil
}

// SetSSLVerification sets the SSL verification poilcy of the client.
func (client *Client) SetSSLVerification(verify bool) error {
transport, ok := client.Transport.(*HTTPTransport)
if !ok {
return fmt.Errorf("No HTTP transport defined for client")
}
httpTransporttransport, ok := transport.Client.Transport.(*http.Transport)
if !ok {
return fmt.Errorf("Couldn't convert http.Client transport to http.Transport")
}
httpTransporttransport.TLSClientConfig.InsecureSkipVerify = !verify
return nil
}

// Sets the DSN for the default *Client instance
func SetDSN(dsn string) error { return DefaultClient.SetDSN(dsn) }

// Sets the SSL Verification for the default *Client instance
func SetSSLVerification(verify bool) error { return DefaultClient.SetSSLVerification(verify) }

// SetRelease sets the "release" tag.
func (client *Client) SetRelease(release string) {
client.mu.Lock()
Expand Down
14 changes: 14 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package raven

import (
"encoding/json"
"net/http"
"reflect"
"testing"
"time"
Expand Down Expand Up @@ -146,6 +147,19 @@ func TestSetDSN(t *testing.T) {
}
}

func TestSetSSLVerification(t *testing.T) {
client := newClient(nil)
err := client.SetSSLVerification(false)
if err != nil {
t.Error("Unable to disable SSL verification:", err)
}
transport := client.Transport.(*HTTPTransport)
httpTransporttransport := transport.Client.Transport.(*http.Transport)
if !httpTransporttransport.TLSClientConfig.InsecureSkipVerify {
t.Error("incorrect ssl verification policy")
}
}

func TestNewClient(t *testing.T) {
client := newClient(nil)
if client.sampleRate != 1.0 {
Expand Down