gpt4 book ai didi

ssl - Netsuite https模块添加自签名证书访问第三方Web Service

转载 作者:太空宇宙 更新时间:2023-11-03 13:05:16 24 4
gpt4 key购买 nike

有谁知道如何使用 Netsuite https 模块将自签名证书文件(.pem 或 .pfx 扩展名)附加到外部 Web 服务来创建请求?

我想使用 map/reduce 脚本自动向西类牙税务登记实体 (SII) 报告发票。我已经使用 POSTMAN 和 CURL 命令行将生成的 XML 测试到 SII Web 界面中,Web 服务收到了我的请求并返回了预期的 XML 响应。但是我无法使用 N/https 模块创建请求来获得相同的结果,主要是因为我不知道如何发送带有附加证书文件的请求。我的脚本失败并显示一条消息:

"type":"error.SuiteScriptError","name":"SSS_CONNECTION_TIME_OUT"

这是我试过的代码:

var siiURL = 'https://www7.aeat.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP';

//get the content of the generated xml
var xml_content = getXMLContent(url);

//get the url of the certificate file that is saved in the NS file cabinet
var certificate = getClientCertificate();
log.audit({ title: 'Certificate File', details: certificate });
var headers = {
'Content-Type': 'text/xml; charset=utf-8',
'SOAPAction': 'SuministroLRFacturasEmitidas',
'local_cert': certificate,
'passphrase': '****'
};
var SIIresponse = https.post({ url: siiURL, body: xml_content, headers: headers });
log.audit({title: 'Response from SII', details: SIIresponse.code + ' | ' + SIIresponse.body });

示例片段取自 PHP 中的一篇文章:https://es.stackoverflow.com/questions/77233/conectar-con-el-web-service-de-sii-aeat-soap-php

西类牙税务报告实体提供了一个 pfx 文件来进行身份验证。出于测试目的,我使用这篇文章创建了一个 PEM 文件(包括 cl 和 key 以及一个 bundle .pem 文件):https://es.stackoverflow.com/a/131407/59793

我猜 Web 服务不希望请求 header 中有证书文件,但我不知道它应该放在哪里,或者是否有合适的 header key 。此外,我找到了有关如何将 .cert/.pem 文件保存到 Netsuite 的信息,但据我所知,这是用于套件商务的:

https://noblue.co.uk/blog/netsuite-tips-installing-an-ssl-certificate-on-suitecommerce

感谢任何帮助或评论。

PD。请原谅任何语法错误或拼写错误。

最佳答案

您可以尝试使用 N/https/clientCertificate 模块:

define(['N/https/clientCertificate'], function (cert) {
....
....
....

var siiURL = 'https://www7.aeat.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP';

//get the content of the generated xml
var xml_content = getXMLContent(url);

var key = "certID";

var headers = {
'Content-Type': 'text/xml; charset=utf-8', // Use application/soap+xml instead??
'SOAPAction': 'SuministroLRFacturasEmitidas'
};

var SIIresponse = cert.post({
url: siiURL,
certId: key,
body: xml_content,
headers: headers
});

log.audit({title: 'Response from SII', details: SIIresponse.code + ' | ' + SIIresponse.body });

....
....
....

关于ssl - Netsuite https模块添加自签名证书访问第三方Web Service,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53380482/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com