Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I specify "--insecure" using this library? #131

Open
ukulililixl opened this issue Oct 29, 2019 · 3 comments
Open

How can I specify "--insecure" using this library? #131

ukulililixl opened this issue Oct 29, 2019 · 3 comments

Comments

@ukulililixl
Copy link

I install openwhisk in ubuntu in my own computer and I can access it using wsk -i ....... However, I have problems using this library to access openwhisk.

For example:
I can run the following command to list all the actions I have created in openwhisk.
wsk -i action list
The output is

actions
/guest/test                                                          private blackbox

However, when I try to do the same thing in a GO program using this library, something wrong happens. Here are my codes:

config := &whisk.Config{
                Host: "http://172.17.0.1",
		Version: "v1",
		Verbose: true,
		Namespace: "_",
		AuthToken: "23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP",
		Debug: true,
		Insecure: true,
	}
client, err := whisk.NewClient(http.DefaultClient, config)

if err != nil {
	fmt.Println(err)
	os.Exit(-1)
}

options := &whisk.ActionListOptions{
        Limit: 30,
  	Skip: 0,
}

actions, resp, err := client.Actions.List("",options)
if err != nil {
        fmt.Println(err)
        os.Exit(-1)
}
fmt.Println("Returned with status: ", resp.Status)
fmt.Println("Returned actions: \n%+v", actions)

The error message is:

The resource requires authentication, which was not supplied with the request (code df76048ef1abc23514e2a73aa26c910b)

I wonder if I did something wrong in the GO program. Thanks!

@ukulililixl
Copy link
Author

The problem is fixed. I just use ~/.wskprop and set AUTH as well as APIHOST in it. Then I can access openwhisk using the following codes:

client, _ := whisk.NewClient(http.DefaultClient, nil)
options := &whisk.ActionListOptions{
	  Limit: 30,
	  Skip: 0,
}
actions, resp, err := client.Actions.List("", options)

New question is, why there is no need to specify something like "--insecure"?

@rabbah
Copy link
Member

rabbah commented Oct 30, 2019

Hello. The first comment shows you’re using http as your app host. Is that correct? If so the insecure option has no effect.

The second comment is puzzling to me as you should be able to use the client without a WskProps file at all.

@ukulililixl
Copy link
Author

Hello. The first comment shows you’re using http as your app host. Is that correct? If so the insecure option has no effect.

The second comment is puzzling to me as you should be able to use the client without a WskProps file at all.

For the first comment, when I remove the configuration of Insecure: true in config, I get the following error:

Get https://172.17.0.1/api/v1/namespaces/_/actions?limit=30&skip=0: x509: cannot validate certificate for 172.17.0.1 because it doesn't contain any IP SANs

I don't know why it is still trying to access openwhisk via https even if I configure http in Host.

For the second comment, I try to remove ~/.wskprops and re-run the program and it fails. It seems that when we create a new client, GetDefaultConfig is called to load default configurations. I guess this function will load data from ~/.wskprops by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants