如何将frisby.js与SSL客户端证书一起使用? [英] How do I use frisby.js with SSL client certificates?

查看:110
本文介绍了如何将frisby.js与SSL客户端证书一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对将Frisby.js与使用SSL客户端证书的REST服务结合使用存在疑问.

I have a question about the use of Frisby.js with a REST service that uses SSL client certificates.

如果我使用Request包与服务进行对话,则可以执行以下操作:

If I use the Request package to talk to the service, I can do something like this:

request.get(URL, {
  agentOptions: {
    // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format:
    pfx: fs.readFileSync(pfxFilePath),
    passphrase: 'password',
    ca: fs.readFileSync(caFilePath)
  }
});

由于Frisby使用了请求,因此我认为我可以在Frisby测试中做类似的事情,但是我似乎无法正确理解语法.

Since Frisby uses request, I assume I can do something similar in a Frisby test, but I can’t seem to get the syntax correct.

您能提出一些可行的建议吗?谢谢...

Can you suggest something that might work? Thanks...

推荐答案

.get().post()方法可以采用其他结构,其内容类似于

The .get() and .post() methods can take an additional struct with contents similar to the options parameter of https.request(). You will need to supply values for (some of): pfx, key, cert, ca and passphrase.

类似这样的东西:

var fs     = require('fs');
var frisby = require('frisby');

frisbee.create( 'Test name' )
  .get(
    'https://localhost/rest/endpoint',
    {
      key:        fs.readFileSync( "/path/to/certificates/certificate.key" ),
      cert:       fs.readFileSync( "/path/to/certificates/certificate.crt" ),
      ca:         fs.readFileSync( "/path/to/certificates/ca.crt" ),
      passphrase: "your pass phrase"
    }
  )
  .expectStatus( 200 )
  .toss();

这篇关于如何将frisby.js与SSL客户端证书一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆