将TLS客户端证书上传到Firebase云功能 [英] Upload TLS client certificate to Firebase cloud functions

查看:68
本文介绍了将TLS客户端证书上传到Firebase云功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定是否可以上载用于Firebase中的云功能的TLS客户端证书.名为

I'm trying to figure out if it is possible to upload a TLS client certificate to be used for my cloud functions in firebase. The TLS client certificate is required by a third-party payment solution called Swish.

这是我的第一个firebase项目,像这样的小问题会使该平台对我不可用似乎很可笑.

This is my first firebase project and it seems silly that a small issue like this will render the platform unusable for me..

推荐答案

经过一番头痛和尝试,我发现了一种非常简单的方法来通过云功能解决支付杂费的问题:

After some headache and trying I found a quite easy way to solve swish-payments through cloud functions:

使用 request-js 而不是内置库,我只需要构建options对象即可在request.post()方法中使用,如下所示:

Using request-js instead of the built in libraries, I only need to build the options object to use in the request.post() method as following:

const swishOptions = {
url: 'LINK TO SWISH SERVER',
json: true,
pfx: fs.readFileSync('cert.p12'),
passphrase: 'swish',
body: swishRequestBody
}

cert.p12文件应与index.js放在同一文件夹中,并将与函数一起上传.

The cert.p12-file should be placed in the same folder as index.js and will be uploaded together with the functions.

rq.post(swishOptions, (err, res) => {
            if (err){
                    console.log('payment creation error: ' + JSON.stringify(err))
                    reject(err)
                }
            if (res){
                    console.log('Payment-token: ' + res.headers.paymentrequesttoken)
                }
        });

主体对象应包含

The body-object should contain all fields specified in the Swish API, use console.log() to read the error-messages from the Swish-server.

这篇关于将TLS客户端证书上传到Firebase云功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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