dqzve68846 2016-11-29 03:18
浏览 203

使用go-gin以编程方式自动接受证书

I am using golang go-gin server for hosting an application. Both the front-end and back-end work over https and both are separate projects. The front-end makes ajax calls to the back-end which is rest API based. If I clear the browser cache (Google Chrome) and try to load the UI it does not communicate with the back-end API initially. Then in another tab I hit the base url (https://localhost:8080/) accept the certificate and then it works. Is there any way to avoid this? I want the front end should auto accept the certificate and not complain about it.

  • 写回答

1条回答 默认 最新

  • duanmen1887 2016-11-29 10:01
    关注

    In tls.Config you can find the Certificates attribute, which could be helpful in your situation:

    Certificates contains one or more certificate chains to present to the other side of the connection. Server configurations must include at least one certificate or else set GetCertificate.

    Then you can use your custom tls.Config to obtain a http.Transport for your purposes

    tr := &http.Transport{
        TLSClientConfig: &tls.Config{...custom config attrs...},
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分