WSClient和SSL

时间:2017-06-21 16:16:54

标签: java scala ssl playframework

在Play 2.4.3网络应用中,我需要使用public class CustomerOrdersModelView { public string CustomerID { get; set; } public int FY { get; set; } public float? price { get; set; } .... .... } public async Task<IActionResult> ProductAnnualReport(string rpt) { var qry = from c in _context.Customers join ord in _context.Orders on c.CustomerID equals ord.CustomerID into co from m in co.DefaultIfEmpty() select new CustomerOrdersModelView { CustomerID = c.CustomerID, FY = c.FY, price = co?.price ?? 0, .... .... }; .... .... } 通过HTTPS调用其他服务。我跟着this MSDN example,但出现错误:

  

play.api.libs.ws.ssl.CompositeCertificateException:没有信任经理   能够验证此证书链:#of exceptions = 1

WSClient内的例外:

  

sun.security.validator.ValidatorException:PKIX路径构建失败:   sun.security.provider.certpath.SunCertPathBuilderException:无法   找到所请求目标的有效证书路径

负责SSL的CompositeCertificateException的一部分:

application.conf

这里有什么问题?

1 个答案:

答案 0 :(得分:2)

我通过以下步骤解决了问题:

  • 运行the discussion her以生成jssecacerts文件。
  • application.conf
  • 中添加文件路径

配置示例:

play.ws.ssl {
  trustManager = {
    stores = [
      {path: "C:/A/B/jssecacerts"}
      {path: ${java.home}/lib/security/cacerts}
    ]
  }
}