【发布时间】:2014-05-22 14:40:58
【问题描述】:
我有在 Windows PE 中运行的 Python Windows 安装脚本。在重新安装期间(使用相同的机器名称),厨师客户端将失败,因为客户端证书已经存在。我试图在重新安装 Window PE 期间从厨师服务器中删除客户端。
我发现pychef 将删除客户端密钥。问题是它需要 OpenSSL,而 OpenSSL 又需要 Visual C++ 2008 Redistributables。我未能成功在 Windows PE 中加载 Visual C++ 2008 Redistributables。我只是尝试复制 DLL,但会引发以下错误。
The application failed to start because its side-by-side configuration is
incorrect. Please see the application event log or use the command-line
sxstrace.exe tool for more detail
有没有办法将 Visual C++ 2008 Redistributables 导入 Windows PE?
或者完全避开这个问题,有没有办法在不使用 OpenSSL 的情况下调用 Chef 服务器?
我正在使用 Python 3.4.1 和 Windows PE 3.0。
编辑:我找到了一个纯 python 的RSA library。我尝试通过替换 Key 类来使用该库而不是 OpenSSL。
import rsa
class Key(object):
def __init__(self, key):
if isinstance(key, str):
if key.startswith('-----'):
# PEM formatted text
key_data = key
else:
key_data = open(key, 'rb').read()
else:
key_data = key.read()
self.private_key = rsa.PrivateKey.load_pkcs1(key_data)
def private_encrypt(self, data):
return rsa.encrypt(data.encode('utf-8'), self.private_key)
代码运行但我返回HTTP Error 401: Unauthorized。
Invalid signature for user or client 'testcert'
我对加密不太了解,所以我认为我只是使用错误的库或需要更改一些设置。纯 python 库是否可以与 Chef 服务器通信?如果是这样,使用它的正确方法是什么?
【问题讨论】:
-
这不是很有帮助,但我不知道 PyChef 是否甚至可以在 Python 3 上运行。
-
有一个 fork 进行更改。那也是我链接的回购。它基本上运行 2to3 并修复了几个 str 到字节错误。我还没有完全测试它,但它适用于我正在使用的东西。
标签: python windows chef-infra