Add InsecureSkipVerify functionality.

This commit is contained in:
Kalle Carlbark 2019-09-11 09:38:29 +02:00
parent 79ae6869a7
commit 62df6ed37f
No known key found for this signature in database
GPG key ID: 3FC0C93C5A5A0670
2 changed files with 11 additions and 4 deletions

View file

@ -3,11 +3,13 @@ package nbclient
type NetBox struct {
RootURL string
Token string
InsecureSkipVerify bool
}
func (n *NetBox) New(root, token string) error {
func (n *NetBox) New(root, token string, TlsSkipVerify bool) error {
n.RootURL = root
n.Token = token
n.InsecureSkipVerify = TlsSkipVerify
return nil
}

View file

@ -2,6 +2,7 @@ package nbclient
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"github.com/pkg/errors"
@ -85,9 +86,13 @@ func (i *Dcim_Interfaces_Create) CreateInterface(n *NetBox) error {
if err != nil {
return err
}
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: n.InsecureSkipVerify},
}
timeout := time.Duration(60 * time.Second)
client := &http.Client{
Timeout: timeout,
Transport: transport,
}
request, err := http.NewRequest("POST", n.RootURL+"/dcim/interfaces/", bytes.NewBuffer(interfaceData))
if err != nil {