意外的“根据验证过程,远程证书无效。 [英] Unexpected " The remote certificate is invalid according to the validation procedure."

查看:99
本文介绍了意外的“根据验证过程,远程证书无效。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Mailkit从.NetCore / Ubuntu计算机连接到SMTP服务器。

I am trying to connect to an SMTP server from a .NetCore/Ubuntu machine via Mailkit.

我试图通过SSL连接到服务器上的端口25

I am attempting to connect to port 25 on the server with SSL turned off.

邮件服务器是本地局域网上的Windows服务器,并且在其他计算机上也可以正常工作,其设置与问题Ubuntu计算机上使用的设置相同。

The mail server is a windows server on the local lan, and works fine from other machines with the same settings as are being used on the problem Ubuntu machine.

用于连接的代码如下:

            using (var client = new SmtpClient())
            {
                client.Connect("smtp.mydomain.com", 25,false);
                client.Authenticate(username, password);
                client.Send(emailMessage);
                client.Disconnect(true);
            }

但是,这会在.Connect行后立即引发异常并显示错误消息
根据验证程序,远程证书无效。

However, this throws an exception immediately after the .Connect line with the error message "The remote certificate is invalid according to the validation procedure."

我很惊讶在25号香草端口上完全涉及证书。

I am surprised that certificates are involved at all on vanilla port 25.

有人知道发生了什么吗?

Has anyone got any ideas what is going on?

推荐答案

服务器可能是启用TLS作为SMTP的一部分。这很常见,是STARTTLS动词。

The server is probably enabling TLS as part of SMTP. This is pretty common, it's the STARTTLS verb.

如果在其他Windows机器上也可以使用,那么您是否在广告中?如果是这样,则AD上可能有一个CA颁发证书,这些证书会通过组策略自动信任。因此,您需要在Ubuntu计算机上配置OpenSSL以信任该CA

If this works on other Windows boxes, are you in an AD? If so there's probably a CA on the AD issuing certificates which are automatically trusted via Group Policy. So you need to configure OpenSSL on your Ubuntu machine to trust that CA too.

或者您可以说他妈的,并告诉StmpClient使用

Or you could just say fuck it, and tell StmpClient to ignore security with

client.EnableSsl = true;

这篇关于意外的“根据验证过程,远程证书无效。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆