I created an angular universal app and followed the following tutorial to use SSL for local development with SSR:
https://medium.com/#dnlcyan/local-angular-ssr-with-https-b9d305dc620d
The certificate is trusted in the browser and also the requests work on browser level. But for request coming from the node server the API throws the following exception:
Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware
Failed to authenticate HTTPS connection. System.IO.IOException:
Received an unexpected EOF or 0 bytes from the transport stream. at
System.Net.Security.SslStream.g__InternalFillHandshakeBufferAsync|189_0[TIOAdapter](TIOAdapter
adap, ValueTask`1 task, Int32 minSize) at
System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter
adapter) at
System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter
adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean
isApm) at
Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.OnConnectionAsync(ConnectionContext
context)
I read something about that the certificate might not be trusted, but I added it to windows and also the browser indicates that it's correct. I tried to create a new certificate according to this tutorial but it doesn't work as well: https://fmoralesdev.com/2020/01/03/serve-angular-app-over-https-using-angular-cli/
Does anyone know what the issue might be here?
I am getting an exception thrown sending an email via SendGrid since recently upgrading a project to .net 4.5.2
Failure sending mail. System.IO.IOException: Unable to read data from
the transport connection: net_io_connectionclosed. at
System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer,
Int32 offset, Int32 read, Boolean readLine) at
System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader
caller, Boolean oneLine) at
System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader
caller) at System.Net.Mail.CheckCommand.Send(SmtpConnection conn,
String& response) at
System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command,
MailAddress from, Boolean allowUnicode) at
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify, Boolean
allowUnicode, SmtpFailedRecipientException& exception) at
System.Net.Mail.SmtpClient.Send(MailMessage message) at
System.Net.Mail.SmtpClient.Send(MailMessage message) at
SendGridMail.Transport.SMTP.SmtpWrapper.Send(MailMessage mime) at
SendGridMail.Transport.SMTP.Deliver(ISendGrid message) at
ReACT.Classes.Business.Helpers.Email.Send(String[] to, String[]
toNames, Boolean ccToSender, String[] ccTo, String[] ccToNames, String
subject, String body, Boolean isHtml, String SMTPServer, String
EmailUserName, String EmailPassword, String EmailPort, String
SystemEmailAddress, String SystemEmailName, String& FriendlyException,
String& TechnicalException)
The code used to send the email via SMTP using the SendGrid service is as follows -
SendGridMail.SendGrid vEmailMessage = SendGridMail.SendGrid.GetInstance(vMailMessage.From, vMailMessage.To.ToArray(), vMailMessage.CC.ToArray(), new MailAddress[0], vMailMessage.Subject, vMailMessage.Body, vMailMessage.Body);
NetworkCredential vCredentials = new NetworkCredential(this.ApplicationSettings.EmailUserName, this.ApplicationSettings.EmailPassword);
var vTransport = SMTP.GetInstance(vCredentials);
//Send email message
vTransport.Deliver(vEmailMessage);
The credentials are correct and confirmed as working correctly. This problem has only started since the .net framework upgrade and unfortunately, we cannot downgrade back to target .net 4
I had the same problem. I had the wrong username. I thought this was the ApiKey that I created for this, I even tried the email with and without domain. The solution was that the SMTP username is "apikey", as in that exact string, not your apikey, not the internal identifier nor the 'friendly' name you gave it. Just the exact 6 letters of "apikey".
For those experiencing the same exception when sending emails via SendGrid, it turned out that a new piece of functionality was passing an incorrect password to the SendGrid API resulting in a AuthenticationFailedException: 535 Authentication failed: Bad username / password.
I discovered this after downloading Wireshark, finding & inspecting the SendGrid packets to find the data sent to the API was incorrect under a certain condition. The SendGrid API then returned a rather helpful AuthenticationFailedException exception however when this exception was caught in a try catch block in code, the actual exception was masked and came out as the aforementioned net_io_connectionclosed IOException
I fixed the bug in our new application and the issue went away. If only the actual exception being thrown by the SendGrid API was the one caught in the try catch block!
const string username="apikey";
string pass = "xxxxxxxxxxxxxxxxxxxxx" // login sendgrid.com => create ApiKey
NetworkCredential vCredentials = new NetworkCredential("apikey", pass);
I have followed this guide
Link: https://sendgrid.com/docs/API_Reference/SMTP_API/integrating_with_the_smtp_api.html
I had the same issue, but it had to do with enabling 2FA in my sendgrid account before upgrading my SMTP and API V3 code to Key-based authentication.
If you enable 2FA before doing the other stuff, it breaks authentication.
For us - this non-descript error was due to reaching the sending limits for our sendgrid email api subscription. I would recommend checking your sendgrid account first before messing about with website settings.
I did notice that a service was sending a lot of messages and using all the 25.000/month messages available in the azure free account plain.
To solve the problem, I created a new account and fixed the service to send a lower number of messages.
I had the same error but it was because I had included a domain parameter in the NetworkCredential
In our case this was a network issue. We had to enable the company's firewall to allow web socket connections from our service to SendGrid/Twilio as the new C# client we had to switch to (SendGridClient) uses sockets. Previously we used the C# generic MailClient which used SMTP/HTTP.
This happens on the sslStream.AuthenticateAsServer(serverCertificate,
true, SslProtocols.Default, true);
call.
I'm trying to do client authentification. I control both client and server, both are c# via sslstream.
When I use a nodejs server, it works perfectly. But I just cant get the serverside to reliably work in c# for some reason. Clearly the ssl authentification needs to wait for the client to choose the client certificate, but apparently this is not a built in feature for c# sslstream class?
I already tried doing this before the call, but it still immediately errors out on the call:
I dont mind the security question in IE. That's fine. I'm concerned with the fact how sslstream does not seem to work at all with such a basic szenario.
Error from wcf trace:
System.Net Error: 0 : [7928] Exception in AppDomain#13869071::UnhandledExceptionHandler - Authentication failed because the remote party has closed the transport stream..
at System.Net.Security.SslState.ValidateCreateContext(Boolean isServer, String targetHost, SslProtocols enabledSslProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, Boolean remoteCertRequired, Boolean checkCertRevocationStatus, Boolean checkCertName)
at System.Net.Security.SslStream.AuthenticateAsServer(X509Certificate serverCertificate, Boolean clientCertificateRequired, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
Adding the below code helped me overcome the issue (I'm running the app in .NET 4.5.1).
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
I'm developing an application which requires SSL encryption between the client and server, and needs to run under Windows and in Ubuntu under Mono. At the moment, the server and client pair works fine in Windows, but when the client connects to the server, the server returns this error:
Error: The authentication or decryption has failed. at
Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback
(IAsyncResult asyncResult) [0x00000] in :0
I'm loading the certificate like this:
X509Certificate2 cert = new X509Certificate2("server.pfx", "<password>");
Current Mono versions do not support SSL connections as server without client certificates.
Either use a client certificate or apply a patch to the source code.
You can find an example of how to do that in my answer to this question.
I am sending an email from a WPF application. When sending as a domain user on the network, the emails sends as expected. However, when I attempt to send email over a VPN connection, I get the following exception:
Exception:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
I have tried using impersonation as well as setting the Credentials on the SmtpClient. Neither seem to work:
using (new ImpersonateUser("myUser", "MYDOMAIN", "myPass"))
{
var client = new SmtpClient("myhost.com");
client.UseDefaultCredentials = true;
client.Credentials = new NetworkCredential("myUser", "myPass", "MYDOMAIN");
client.Send(mailMessage);
}
I've also tried using Wireshark to view the message over the wire, but I don't know enough about SMTP to know what I'm looking for.
One other variable is that the machine I'm using on the VPN is Vista Business and the machine on the network is Win7. I don't think it's related, but then I wouldn't be asking if I knew the issue! :)
Any ideas?
I solved this by connecting outlook on a VPN machine to the Exchange server. The IP address automatically resolved to a different server name than the one I was trying. Evidently the exchange server was only available over VPN through the other URL.