Add ca.WithInsecure and use methods for file names

pull/692/head
max furman 3 years ago
parent e5951fd84c
commit d777fc23c2

@ -226,7 +226,7 @@ func (o *clientOptions) getTransport(endpoint string) (tr http.RoundTripper, err
return tr, nil return tr, nil
} }
// WithTransport adds a custom transport to the Client. It will fail if a // WithTransport adds a custom transport to the Client. It will fail if a
// previous option to create the transport has been configured. // previous option to create the transport has been configured.
func WithTransport(tr http.RoundTripper) ClientOption { func WithTransport(tr http.RoundTripper) ClientOption {
return func(o *clientOptions) error { return func(o *clientOptions) error {
@ -238,6 +238,17 @@ func WithTransport(tr http.RoundTripper) ClientOption {
} }
} }
// WithInsecure adds a insecure transport that bypasses TLS verification.
func WithInsecure() ClientOption {
return func(o *clientOptions) error {
o.transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
return nil
}
}
// WithRootFile will create the transport using the given root certificate. It // WithRootFile will create the transport using the given root certificate. It
// will fail if a previous option to create the transport has been configured. // will fail if a previous option to create the transport has been configured.
func WithRootFile(filename string) ClientOption { func WithRootFile(filename string) ClientOption {

@ -72,11 +72,11 @@ func LoadDefaultIdentity() (*Identity, error) {
} }
func profileConfigDir() string { func profileConfigDir() string {
return filepath.Join(step.ProfilePath(), "config") return filepath.Join(step.Path(), "config")
} }
func profileIdentityDir() string { func profileIdentityDir() string {
return filepath.Join(step.ProfilePath(), "identity") return filepath.Join(step.Path(), "identity")
} }
// WriteDefaultIdentity writes the given certificates and key and the // WriteDefaultIdentity writes the given certificates and key and the

@ -376,15 +376,12 @@ func New(o apiv1.Options, opts ...Option) (*PKI, error) {
} }
// Create profile directory and stub for default profile configuration. // Create profile directory and stub for default profile configuration.
if currentCtx := step.GetCurrentContext(); currentCtx != nil { if currentCtx := step.Contexts().GetCurrent(); currentCtx != nil {
profile := GetProfileConfigPath() profile := GetProfileConfigPath()
if err := os.MkdirAll(profile, 0700); err != nil { if err := os.MkdirAll(profile, 0700); err != nil {
return nil, errs.FileError(err, profile) return nil, errs.FileError(err, profile)
} }
if p.profileDefaults, err = getPath(profile, "defaults.json"); err != nil { if err := ioutil.WriteFile(step.ProfileDefaultsFile(),
return nil, err
}
if err := ioutil.WriteFile(p.profileDefaults,
[]byte("{}"), 0600); err != nil { []byte("{}"), 0600); err != nil {
return nil, err return nil, err
} }

Loading…
Cancel
Save