Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-SkipCertificateValidatation does not seem to work #53

Open
tonyguadagno opened this issue Mar 18, 2024 · 2 comments
Open

-SkipCertificateValidatation does not seem to work #53

tonyguadagno opened this issue Mar 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@tonyguadagno
Copy link

hi, i am executing this command:

Send-EmailMessage -to "[email protected]" -From "[email protected]" -Subject "test" -Text "test" -Server "mail.company.com" -port 25 -SkipCertificateValidatation

the cert on port 25 does NOT match "mail.company.com" but i am using the -SkipCertificateValidatation switch....this is what i get:

WARNING: Send-EmailMessage - Error: Exception calling "Connect" with "3" argument(s): "An error occurred while attempting to establish an SSL or TLS connection.

The host name did not match the name given in the server's SSL certificate.
"
WARNING: Send-EmailMessage - Possible issue: Port? (25 was used), Using SSL? (Auto was used). You can also try SkipCertificateValidation or SkipCertificateRevocation. 


Status        : False
Error         : Exception calling "Connect" with "3" argument(s): "An error occurred while attempting to establish an SSL or TLS connection.
                
                The host name did not match the name given in the server's SSL certificate.
                "
SentTo        : [email protected]
SentFrom      : [email protected]
Message       : 
TimeToExecute : 00:00:00.0235829
Server        : mail.company.com
Port          : 25

so, why is this happening? Am I doing something wrong?
thanks

@PrzemyslawKlys
Copy link
Member

It was also reported in:

Seems this PR:

Broke it. @jborean93 do you think I should revert back?

@PrzemyslawKlys PrzemyslawKlys added the bug Something isn't working label Apr 24, 2024
@jborean93
Copy link
Contributor

I'm unsure why it wouldn't work, it looks like v3.2.0 is the version of MailKit that is used and the code that calls this callback is

https://github.com/jstedfast/MailKit/blob/77eb92573cec5b38bafb3a1ebdd819693ac4162f/MailKit/Net/Smtp/SmtpClient.cs#L528-L551

It's the same place that also checks the [Net.ServicePointManager]::ServerCertificateValidationCallback so both should work. Maybe pwsh class inheritance is causing problems with the type where property isn't set but that's a stretch. I don't have a mail server to test it out currently sorry so up to you if you wish to revert or investigate why the property doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants