【问题标题】:PEM Certificate in Data Factory数据工厂中的 PEM 证书
【发布时间】:2021-12-27 14:04:06
【问题描述】:

在这方面找不到任何东西。

我正在为 On the market 开发一个 API,这是一个英国房地产网站。作为身份验证的一部分,它要求我们提交证书和密钥。文档在这里:

https://media.rightmove.co.uk/ps/pdf/guides/adf/Rightmove_Real_Time_Datafeed_Specification.pdf

(注意:文档指的是 Rightmove,但市场上使用相同的 API)。

我在数据工厂中看不到任何功能可以做到这一点,有没有人能够克服类似的挑战?

我从 On-the-market 下载了 PEM 证书。我尝试使用 Databricks 脚本进行测试,但在尝试加载证书时收到错误消息:

Python 脚本:

import http.client
import json
import ssl
 
# Defining certificate related stuff and host of endpoint
certificate_file = "/mnt/data/certificates/otm/certificate17131114507144750725.pem"
certificate_secret= "<snipped>"
host = 'https://adfapi.rightmove.co.uk/v1'
 
# Defining parts of the HTTP request
request_url='/property/getbrandemail'
request_headers = {
    'Content-Type': 'application/json'
}
     
# Define the client certificate settings for https connection
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.load_cert_chain(certfile=certificate_file, password=certificate_secret)
 
# Create a connection to submit HTTP requests
connection = http.client.HTTPSConnection(host, port=443, context=context)
 
# Use connection to submit a HTTP POST request
connection.request(method="POST", url=request_url, headers=request_headers, body=json.dumps(request_body_dict))
 
# Print the HTTP response from the IOT service endpoint
response = connection.getresponse()
print(response.status, response.reason)
data = response.read()
print(data)

错误信息:

FileNotFoundError: [Errno 2] 没有这样的文件或目录 -------------------------------------------------- ------------------------- FileNotFoundError Traceback(最近一次调用 最后)在 20 # 定义 https 连接的客户端证书设置 21 上下文 = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ---> 22 context.load_cert_chain(certfile=certificate_file, password=certificate_secret) 23 24 # 创建连接以提交 HTTP 请求

需要明确的是,错误与此行有关:

context.load_cert_chain(certfile=certificate_file, password=certificate_secret)

/mnt/data 是我创建的挂载点,可以在其他笔记本中正常工作。我的想法是通过笔记本获得响应并通过 ADF 进行编排。感觉应该有更简单的解决方案。

【问题讨论】:

    标签: python azure-data-factory-2 azure-databricks pem


    【解决方案1】:

    问题是您使用的代码中的/mnt/data 对 DBFS(默认文件系统)一无所知。所以你需要使用local filesystem API - 只需将/dbfs 添加到所有路径,例如/dbfs/mnt/data/...

    【讨论】:

    • 谢谢 - 这是正确的,因为该错误建议特定于 Databricks。仍然有一个 Python 问题,我将提出一个新问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 1970-01-01
    • 2013-12-21
    • 2016-02-03
    • 1970-01-01
    相关资源
    最近更新 更多