我有一个当前使用 SSL 的 ProGet 服务器,并且需要客户端证书才能与其通信。我们希望能够直接从命令行或在 Visual Studio 包管理器中使用此服务器。
当通过浏览器访问时,查看存储库没有问题。在命令行上使用 nuget.exe 时,结果为 403 Forbidden。我使用 Fiddler 来监视请求,它突出显示服务器正在请求客户端证书,Fiddler 允许您注入(inject)所需的证书,然后 nuget 请求成功。
是否可以在使用 NuGet 时提供客户端证书:
nuget install PackageName -Source https://myhost -Cert ???
或者对于这样的设置,我们将不得不退回到使用 API key 来获得访问权限?
我们可以在使用 Visual Studio 时提供证书吗?
最佳答案
从 NuGet 5.7.2 开始,您可以使用 client-cert feature .
配置示例:
<configuration>
...
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Contoso" value="https://contoso.com/packages/" />
<add key="Example" value="https://example.com/bar/packages/" />
</packageSources>
...
<clientCertificates>
<storeCert packageSource="Contoso"
storeLocation="currentUser"
storeName="my"
findBy="thumbprint"
findValue="4894671ae5aa84840cc1079e89e82d426bc24ec6" />
<fileCert packageSource="Example"
path=".\certificate.pfx"
password="..." />
<fileCert packageSource="Bar"
path=".\certificate.pfx"
clearTextPassword="..." />
</clientCertificates>
...
</configuration>
您也可以使用 nuget client-certs
CLI 命令进行配置。
关于ssl - 让 Nuget 使用 SSL 将客户端证书传递到私有(private) ProGet 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42096554/