C# 与卡夫卡的证书颁发
我在AWS中用C#编写了一个lambda函数,它试图发布关于卡夫卡主题的消息。 但是,在发布消息时,我会间歇性地出现以下错误 ssl.ca.location失败:by_file.c:260:错误:0B084009:x509证书例程:x509_load_cert_crl_file:PEM lib::invalidoOperationExceptionC# 与卡夫卡的证书颁发,c#,apache-kafka,aws-lambda,C#,Apache Kafka,Aws Lambda,我在AWS中用C#编写了一个lambda函数,它试图发布关于卡夫卡主题的消息。 但是,在发布消息时,我会间歇性地出现以下错误 ssl.ca.location失败:by_file.c:260:错误:0B084009:x509证书例程:x509_load_cert_crl_file:PEM lib::invalidoOperationException public async Task WorkOrderEventHandler(SQSEvent workOrderEvent, ILambdaCo
public async Task WorkOrderEventHandler(SQSEvent workOrderEvent, ILambdaContext context)
{
if (!(File.Exists("/tmp/combined.pem") && File.Exists("/tmp/ca-cert.pem") && File.Exists("/tmp/cert.cer")))
{
Console.WriteLine("Certificates not found");
DownloadCertificates();
}
var producerConfig = new ProducerConfig
{
SslKeyLocation = "/tmp/combined.pem",
SslCaLocation = "/tmp/ca-cert.pem",
SslCertificateLocation = "/tmp/cert.cer",
BootstrapServers = _bootStrapServers,
SecurityProtocol = SecurityProtocol.Ssl
};
Console.WriteLine($"processing message {workOrderEvent.Records.First().Body}");
using var producer = new ProducerBuilder<Null, string>(producerConfig).Build();
foreach (var message in workOrderEvent.Records)
{
await ProcessMessageAsync(producer, message, context);
}
}
public异步任务workOrderEvent处理器(SQSEvent workOrderEvent,ilambdac上下文)
{
如果(!(File.Exists(“/tmp/combined.pem”)&&File.Exists(“/tmp/ca-cert.pem”)&&File.Exists(“/tmp/cert.cer”))
{
Console.WriteLine(“未找到证书”);
下载证书();
}
var PRODUCTERCONFIG=新PRODUCTERCONFIG
{
SslKeyLocation=“/tmp/combined.pem”,
SSLCAPLOCATION=“/tmp/ca-cert.pem”,
SslCertificateLocation=“/tmp/cert.cer”,
bootstrapserver=\u bootstrapserver,
SecurityProtocol=SecurityProtocol.Ssl
};
WriteLine($“正在处理消息{workOrderEvent.Records.First().Body}”);
使用var producer=new ProducerBuilder(producerConfig.Build();
foreach(workOrderEvent.Records中的var消息)
{
等待ProcessMessageAsync(生产者、消息、上下文);
}
}
我已经将前面lambda的function()方法中的证书从S3下载到lambda可用的/tmp文件夹中
大多数情况下,出版业运作良好,但也有几次失败,原因不明