如何在gocloak中跳过(X509)证书验证?

我正在尝试使用gocloak从 keycloak 验证我的令牌,并为此使用以下代码。


token:=""

client:= gocloak.NewClient("https://example.com")

_, err := client.RetrospectToken(token,"client-id" ,"client-secret", "realm")

log.Print(err.Error())

我遇到以下错误,


Post https://example.com/auth/realms/realm/protocol/openid-connect/token/introspect: x509: certificate signed by unknown authority


有什么办法可以跳过 gocloak 中的证书验证吗?


波斯汪
浏览 44回答 1
1回答

米琪卡哇伊

因此,您正在寻找跳过 TLS 中的证书验证的方法,请尝试使用RestyClienttoken:=""client := gocloak.NewClient(serverURL)restyClient := client.RestyClient()restyClient.SetDebug(true)restyClient.SetTLSClientConfig(&tls.Config{ InsecureSkipVerify: true })_, err := client.RetrospectToken(token,"client-id" ,"client-secret", "realm")log.Print(err.Error())
打开App,查看更多内容
随时随地看视频慕课网APP