mittwald / goharbor-client

Go Client for the Harbor container registry
MIT License
109 stars 50 forks source link

x509: certificate is valid for {private_harbor_host} #149

Open Wall1e opened 2 years ago

Wall1e commented 2 years ago

how to make InsecureSkipVerify==true

zhangguanzhang commented 2 years ago

same issue

wdt1988520 commented 2 years ago

same issue

wdt1988520 commented 2 years ago

func NewRESTClientForHost(u, username, password string, opts config.Options) (RESTClient, error) { if !strings.HasSuffix(u, v2URLSuffix) { u += v2URLSuffix } harborURL, err := url.Parse(u) if err != nil { return nil, err } //构建客户端时, InsecureSkipVerify==true ,临时使用

authInfo := runtimeclient.BasicAuth(username, password)
    if harborURL.Scheme == "https" {
        var optsTLS runtimeclient.TLSClientOptions
        optsTLS.InsecureSkipVerify = true
        client, err := runtimeclient.TLSClient(optsTLS)
        if err != nil {
            return nil, err
        }
        v2SwaggerClient := v2client.New(runtimeclient.NewWithClient(harborURL.Host, harborURL.Path, []string{harborURL.Scheme}, client), strfmt.Default)
        return NewRESTClient(v2SwaggerClient, opts, authInfo), nil
    } else {
        v2SwaggerClient := v2client.New(runtimeclient.New(harborURL.Host, harborURL.Path, []string{harborURL.Scheme}), strfmt.Default)
        return NewRESTClient(v2SwaggerClient, opts, authInfo), nil
    }

}

shaxiaozz commented 2 years ago

@wdt1988520 How to use it? Specifically, modify the source file of that version Looking forward for your response, thank you