我想使用 python 实现基本的 GDS(全球发现服务器)功能 https://github.com/FreeOpcUa/opcua-asyncio。 据我所知,目前 freeopcaua 具有可用于此过程的所有方法,但 CreateSigningRequest https://reference.opcfoundation.org/GDS/v104/docs/7.7.6 除外。我正在寻找有关如何自己执行此操作的提示。
我尝试使用https://opcua-asyncio.readthedocs.io/en/latest/api/asyncua.client.html#asyncua.client.ua_client.UaClient.call但它似乎是错误的方式。
编辑: 我尝试了以下代码:
client = Client(url=url)
await client.set_security(
SecurityPolicyBasic256Sha256,
certificate=r"C:\other\my_cert.der", # cert,
private_key=r"C:\other\my_private_key.pem", # private_key,
)
async with client:
csr_method = client.get_node(f"ns=3; i={ObjectIds.CreateSigningRequestMethodType}")
cert = await client.nodes.server.call_method(csr_method)
但结果:
asyncua.ua.uaerrors._auto.BadMethodInvalid: "The method id does not refer to a method for the specified object."(BadMethodInvalid)
您需要将对象添加到调用中:
client = Client(url=url)
await client.set_security(
SecurityPolicyBasic256Sha256,
certificate=r"C:\other\my_cert.der", # cert,
private_key=r"C:\other\my_private_key.pem", # private_key,
)
async with client:
csr_method = NodeId(ObjectIds.CreateSigningRequestMethodType)
server_config = client.get_node(ObjectIds.ServerConfiguration)
args = (...,...,...,...)
cert = await server_config.call(csr_method, args)