Skip to content

Commit

Permalink
Support client certificate on cli and nginx (#2427)
Browse files Browse the repository at this point in the history
In order to increase the security of auth, it is necessary to add client
certificate on cli and nginx. So user can use wsk -i property set --cert
openwhisk-client-cert.pem --key openwhisk-client-key.pem to pass client
certificate to nginx. If you don't want to use default client certificate
which system provides, you can create your own client certificate instead
of them.
  • Loading branch information
ningyougang authored and csantanapr committed Jul 21, 2017
1 parent 08e3d59 commit b3d194d
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions whisk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ type Client struct {
}

type Config struct {
Namespace string // NOTE :: Default is "_"
AuthToken string
Host string
BaseURL *url.URL // NOTE :: Default is "openwhisk.ng.bluemix.net"
Version string
Verbose bool
Namespace string // NOTE :: Default is "_"
Cert string
Key string
AuthToken string
Host string
BaseURL *url.URL // NOTE :: Default is "openwhisk.ng.bluemix.net"
Version string
Verbose bool
Debug bool // For detailed tracing
Insecure bool
}
Expand All @@ -81,9 +83,18 @@ func NewClient(httpClient *http.Client, config *Config) (*Client, error) {
// Disable certificate checking in the dev environment if in insecure mode
if config.Insecure {
Debug(DbgInfo, "Disabling certificate checking.\n")

tlsConfig := &tls.Config{
InsecureSkipVerify: true,
var tlsConfig *tls.Config
if config.Cert != "" && config.Key != "" {
if cert, err := tls.LoadX509KeyPair(config.Cert, config.Key); err == nil {
tlsConfig = &tls.Config{
Certificates: []tls.Certificate{cert},
InsecureSkipVerify: true,
}
}
}else{
tlsConfig = &tls.Config{
InsecureSkipVerify: true,
}
}

http.DefaultClient.Transport = &http.Transport{
Expand Down

0 comments on commit b3d194d

Please sign in to comment.