我正在尝试做相同的事情:
curl -X POST --data <json> --key <path to key> --cert <path to cert> --cacert <path to cacert> --header "Content-Type: application/json" <url>
在一个安莎的游戏中。根据{{3}}的文档,有关键,证书,X,标题和数据的等价物,但我没有找到传递证书颁发机构文件的方法。
我试过了:
environment:
CURL_CA_BUNDLE: <path to cacert>
uri:
url: <url>
client_cert: <path to cert>
client_key: <path to key>
body: <json>
method: POST
body_format: json
因为man curl指定它将读取环境变量CURL_CA_BUNDLE
。我也尝试过:
uri:
url: <url>
client_cert: <path to cert>
client_key: <path to key>
body: <json>
method: POST
body_format: json
others: --cacert <path to cacert>
这两种方法都没有奏效。没有cacert,我收到错误:“无法验证<url>
的SSL证书。确保您的托管系统安装了有效的CA证书......”。我知道如果我传入validate_certs=False
,那么该方法将起作用,我知道它可以通过命令行使用curl。
我是否可以传入URI模块以绕过此问题?
答案 0 :(得分:3)
uri
module不是cURL,它是完整的python实现。因此,cURL环境或选项无法发挥作用
others
选项记录为“文件模块接受的所有参数也在此处工作”,因此它只表示您可以使用owner
,group
,mode
等将属性设置为dest
。
client_cert
和client_key
以修复issue #18141,他们没有考虑服务器TLS身份验证...
我可以看到3个解决方案:
uri
任务的目标主机上) - 仅对python&gt; = 2.7.9 validate_certs: no
选项禁用服务器证书验证(因此不使用CA证书)cacert
选项的支持答案 1 :(得分:1)
在任务级别使用 SSL_CERT_FILE
环境变量。前任:
- name: test uri using a custom cacert file
environment:
SSL_CERT_FILE: "{{ cacert_file_path }}"
uri:
url: "{{ uri_url }}"
答案 2 :(得分:0)
首先,禁用 SSL 证书验证不是解决方案,而是一种变通方法。 其次,// NOTE: "full_data" is the data source (i.e res.data, in your case).
var config = {
type: 'line',
data: {
labels: Object.keys(full_data.timeline.cases),
showTooltips: true,
datasets: [{
label: "Covid-19 Cases", //CASES DATASET
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "#eb1515",
borderCapStyle: "butt",
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: "miter",
pointBorderColor: "#eb1515",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#eb1515",
pointHoverBorderColor: "#eb1515",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
maintainAspectRatio: false,
data: Object.values(full_data.timeline.cases)
}, {
label: "Covid-19 Deaths", //DEATHS DATASET
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "#1a1c1a",
borderCapStyle: "butt",
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: "miter",
pointBorderColor: "#1a1c1a",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#1a1c1a",
pointHoverBorderColor: "#1a1c1a",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
maintainAspectRatio: false,
data: Object.values(full_data.timeline.deaths)
}, {
label: "Covid-19 Recoveries", //RECOVERIES DATASET
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "#0ec90e",
borderCapStyle: "butt",
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: "miter",
pointBorderColor: "#0ec90e",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#0ec90e",
pointHoverBorderColor: "#0ec90e",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
maintainAspectRatio: false,
data: Object.values(full_data.timeline.recovered)
}]
},
options: {
responsive: true,
title: {
display: true,
text: 'Chart.js Line Chart'
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Dates'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
},
}]
}
}
};
的路径因您的 Linux 发行版而异。这是使 Ansible 模块 (Python) 在 Debian 发行版中识别 SSL 证书的示例,这在我的情况下有效。
(我知道问题与 SSL_CERT_FILE
模块有关,但该解决方案应该适用于 Ansible 模块)
更新证书包后,例如通过 uri
,
update-ca-certificates
答案 3 :(得分:0)
拉取请求 https://github.com/ansible/ansible/pull/71979 向 // create single, shared Subject
let webRequestTriggers = new Subject();
// subscribe to the Subject once at the beginning
function initialise() {
webRequestTriggers.pipe(
switchMap(currentState => this.vehiclesService.getVehiclesByPage(currentState))
)
.subscribe(success => {
this.cache[backendPage] = true;
this.setPageResult({ ...success, page: backendPage, pageSize: pageInfo.pageSize * 10 });
});
}
// probably in some kind of event handler or function that you have defined somewhere, which is called whenever a page of results is requested
function fetchPagedResults(currentState) {
webRequestTriggers.next(currentState);
}
模块添加了一个 ca_path
参数,该参数允许指定包含用于验证的 CA 证书的文件(请参阅{{3} }).