我已经有一个 .pem 和一个 .key 文件,我不想在本地安装/导入它,只需告诉我的客户使用它们,这可能吗?它不是自签名证书
基本上,在我的卷曲中,我做了这样的事情:
curl --key mykey.key --cert mycert.pem https://someurl.com/my-endpoint
Run Code Online (Sandbox Code Playgroud)
我已经检查过这个答案
还有这个https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/CustomTrust.java(但可能没有意义,因为我没有得到该类型的对象我需要)
基本上我有我的 okHttpClient
val okHttpClient = OkHttpClient.Builder()
.sslSocketFactory(?, ?) //here I tried to call sslSocketFactory, trustManager following the example from the CustomTrust.java
.build()
Run Code Online (Sandbox Code Playgroud)
有什么解决方案的想法吗?
也检查了此文档,但 ssl 部分未完成,示例中也未完成
https://square.github.io/okhttp/https/#customizing-trusted-certificates-kt-java
所以我尝试这样做(基于 okhttp 示例)
private fun trustedCertificatesInputStream(): InputStream {
val comodoRsaCertificationAuthority = (""
+ "-----BEGIN CERTIFICATE-----\n" +
"-----END CERTIFICATE-----")
return Buffer()
.writeUtf8(comodoRsaCertificationAuthority)
.inputStream()
}
val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}
fun createClient() : OkHttpClient …Run Code Online (Sandbox Code Playgroud) 现在我正在寻找有关如何通过HttpComponentsMessageSender(不相关)重写客户端x509证书身份验证的弃用解决方案的任务的解决方案.
例如,弃用的解决方案是:
SSLSocketFactory lSchemeSocketFactory = new SSLSocketFactory(this.keyStore, this.keyStorePassword);
Scheme sch = new Scheme("https", 443, lSchemeSocketFactory);
DefaultHttpClient httpClient = (DefaultHttpClient)getHttpClient();
httpClient.getConnectionManager().getSchemeRegistry().register(sch);
Run Code Online (Sandbox Code Playgroud)
作为我使用的CloseableHttpClient的新解决方案:
SSLContextBuilder sslContextBuilder = SSLContexts.custom()
// this key store must contain the key/cert of the client
.loadKeyMaterial(keyStore, keyStorePassword.toCharArray());
if (trustStore != null) {
// this key store must contain the certs needed and trusted to verify the servers cert
sslContextBuilder.loadTrustMaterial(trustStore);
}
SSLContext sslContext = sslContextBuilder.build();
LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
// Create a registry of custom connection socket factories for …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用添加新包poetry add,但它总是出现此错误:
HTTPSConnectionPool(host='10.140.240.64', port=443): Max retries exceeded with url: /api/v4/projects/118/packages/pypi/files/47f05b39ebe470235b70724fb049985ea75fad6c1a5007ad3462f3d430da338b/tg_client-0.1.10-py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)')))
谁知道如何跳过这个验证?
更新:
我尝试从私有存储库添加包:
[[tool.poetry.source]]
name = "my_package"
url = "https://..."
secondary = true
Run Code Online (Sandbox Code Playgroud)
也许这就是解决方案poetry config certificates.my_package.cert false不起作用的原因。
如何从给定的 URL 获取根 SSL 证书以及任何中间证书到文件?理想情况下通过一些 linux shell 兼容的命令行,但如果必须的话也可以手动完成。 更新:交互式地,使用 Chrome,如果我检查证书,我可以选择导出它。如果适用的话,有一种方法可以抓住整个链条。所以现在我只是在寻找一种可编写脚本的方法。
背景:
mono nuget.exe install ./packages.config -o ./packages
Run Code Online (Sandbox Code Playgroud)
将会在 ubuntu 上安装项目包,只要在机器的 Trust store 中安装了所需的证书即可。部分来说,它是这样完成的:
$ certmgr -ssl https://nugetgallery.blob.core.windows.net
Run Code Online (Sandbox Code Playgroud)
此命令带有 -ssl 选项,从指定的 url 获取证书和任何中间体,并需要用户确认。我正在尝试自动化服务器构建,因此我想在不需要用户确认的情况下添加证书。
我尝试将响应通过管道传输到命令中 - 即:
$ echo "Yes" | certmgr -ssl https://nugetgallery.blob.core.windows.net
Run Code Online (Sandbox Code Playgroud)
那是行不通的。我尝试将证书导出到文件,以便将它们添加到我的构建项目中,但 mono certmgr 尚未实现“放置”。
我正在使用 SendGrid 发送电子邮件 .net5 windows 服务,当我从 Visual Studio 本地运行应用程序时,它按预期工作。SendEmailAsync但当我在 Docker 中运行应用程序时,它给出了一个例外。
例外:
由于证书链中的错误,远程证书无效:UntrustedRoot
List<Personalization> personalizations = new List<Personalization>();
Personalization personalization = new Personalization();
personalization.From = new EmailAddress(emailDetails.SenderMailID);
personalization.Tos = GetRecipientsList(emailDetails.RecipientMailID);
personalization.Subject = emailDetails.Subject;
personalizations.Add(personalization);
var msg = new SendGridMessage
{
From = new EmailAddress(emailDetails.SenderMailID),
Subject = emailDetails.Subject
};
msg.AddContent(MimeType.Html, emailDetails.Message);
msg.Personalizations = personalizations;
var sendGridClient = new SendGridClient(apiKey);
var sendGridResponse = await sendGridClient.SendEmailAsync(msg);
Run Code Online (Sandbox Code Playgroud)
Docker 文件:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your …Run Code Online (Sandbox Code Playgroud)