---- Update 27.11.2020 --------------
As I was not able to post the update as response to the response below (error message "1000 characters exceeded") , I had to update my original post.
****Serious general question:
-> Can it really be, that this forum does not allow more then 1'000 characters?!?):
- If yes, this forum is not usable!!****
My reply -----------------------------------------------------------------
First, thanks for your reply
I have nothing special in my program.cs (code see below):
- Read.ini file
- Set some public variables
- Load some images in Base64String's
I further have no specific code to the cert in the app (the cert is applied in appsetings.json (see my first posting)
But maybe I have solved the problem "implicitly" (to early to be sure):
- For other reasons, I have added a
redirect from http to https** a few days ago in startup.cs:**
- Since then, it seems, I had no more crashes in the console (but as I worte above, its to early to be sure, that this redirect has solved the issue).
I cannot control, what kind of users/(hacker-)tools access the app over the internet.
So... from my point of view (not to comprehend / provoke by use the "legal" app over standard browser over https) this may be a plausible reason.
Can it be from your point of view, that access over http have caused the issue?
Added code in startup.cs
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
app.UseRewriter(new RewriteOptions().AddRedirectToHttps(StatusCodes.Status301MovedPermanently, 443));
}
Code in program.cs:
public class Program
{
public static void Main(string[] args)
{
GV.bFehler_Ini = false;
try
{
var iniconfig = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddIniFile("matrixGuide.ini", optional: false, reloadOnChange: true)
.Build();
string cURL = iniconfig.GetValue<string>("Startup:URL");
string PfadDokumente = iniconfig.GetValue<string>("Parameter:PfadDokumente");
string PfadPortalDokumente = iniconfig.GetValue<string>("Parameter:PfadPortalDokumente");
string PfadTemp = iniconfig.GetValue<string>("Parameter:PfadTemp");
string PfadFotoVorlagen = iniconfig.GetValue<string>("Parameter:PfadFotoVorlagen");
string Umgebung = iniconfig.GetValue<string>("Parameter:Umgebung");
// SMTP-Parameter
string SMTPServer = iniconfig.GetValue<string>("Parameter:SMTPServer"); // zrhms100
int SMTPPort = iniconfig.GetValue<int>("Parameter:SMTPPort"); // 25
string SMTPAbsender = iniconfig.GetValue<string>("Parameter:SMTPAbsender"); // Portal@MatrixGuide.ch
string SMTPKennung = iniconfig.GetValue<string>("Parameter:SMTPKennung"); // leer -> noch nicht genutzt
string SMTPPW = iniconfig.GetValue<string>("Parameter:SMTPPW");
GV.cURL = cURL;
GV.PfadDokumente = PfadDokumente;
GV.PfadPortalDokumente = PfadPortalDokumente;
GV.PfadFotoVorlagen = PfadFotoVorlagen;
GV.PfadTemp = PfadTemp;
GV.Umgebung = Umgebung;
GV.SMTPServer = SMTPServer;
GV.SMTPPort = SMTPPort;
GV.SMTPAbsender = SMTPAbsender;
GV.SMTPKennung = SMTPKennung;
GV.SMTPPW = SMTPPW;
string FileMann = GV.PfadFotoVorlagen + "Symbol_Mann.jpg";
Image ImageMann = Image.FromFile(FileMann);
string Base64StringMann = ZF.BitmapToBase64(ImageMann);
GV.GrafikSymbolMann = Base64StringMann;
//
string FileFrau = GV.PfadFotoVorlagen + "Symbol_Frau.jpg";
Image ImageFrau = Image.FromFile(FileFrau);
string Base64StringFrau = ZF.BitmapToBase64(ImageFrau);
GV.GrafikSymbolFrau = Base64StringFrau;
string File_Vorlage_Beauty_Grid = GV.PfadFotoVorlagen + "Vorlage_Beauty_Grid.jpg";
Image ImageVorlage_Beauty_Grid = Image.FromFile(File_Vorlage_Beauty_Grid);
string Base64StringVorlage_Beauty_Grid = ZF.BitmapToBase64(ImageVorlage_Beauty_Grid);
GV.Vorlage_Beauty_Grid = Base64StringVorlage_Beauty_Grid;
//
string File_Vorlage_Beauty_WirUeberUns = GV.PfadFotoVorlagen + "Vorlage_Beauty_WirUeberUns.jpg";
Image ImageVorlage_Beauty_WirUeberUns = Image.FromFile(File_Vorlage_Beauty_WirUeberUns);
string Base64StringVorlage_Beauty_WirUeberUns = ZF.BitmapToBase64(ImageVorlage_Beauty_WirUeberUns);
GV.Vorlage_Beauty_WirUeberUns = Base64StringVorlage_Beauty_WirUeberUns;
string File_Vorlage_Freizeit_Grid = GV.PfadFotoVorlagen + "Vorlage_Freizeit_Grid.jpg";
Image ImageVorlage_Freizeit_Grid = Image.FromFile(File_Vorlage_Freizeit_Grid);
string Base64StringVorlage_Freizeit_Grid = ZF.BitmapToBase64(ImageVorlage_Freizeit_Grid);
GV.Vorlage_Freizeit_Grid = Base64StringVorlage_Freizeit_Grid;
string File_Vorlage_Freizeit_WirUeberUns = GV.PfadFotoVorlagen + "Vorlage_Freizeit_WirUeberUns.jpg";
Image ImageVorlage_Freizeit_WirUeberUns = Image.FromFile(File_Vorlage_Freizeit_WirUeberUns);
string Base64StringVorlage_Freizeit_WirUeberUns = ZF.BitmapToBase64(ImageVorlage_Freizeit_WirUeberUns);
GV.Vorlage_Freizeit_WirUeberUns = Base64StringVorlage_Freizeit_WirUeberUns;
string File_Vorlage_Gourmet_Grid = GV.PfadFotoVorlagen + "Vorlage_Gourmet_Grid.jpg";
Image ImageVorlage_Gourmet_Grid = Image.FromFile(File_Vorlage_Gourmet_Grid);
string Base64StringVorlage_Gourmet_Grid = ZF.BitmapToBase64(ImageVorlage_Gourmet_Grid);
GV.Vorlage_Gourmet_Grid = Base64StringVorlage_Gourmet_Grid;
string File_Vorlage_Gourmet_WirUeberUns = GV.PfadFotoVorlagen + "Vorlage_Gourmet_WirUeberUns.jpg";
Image ImageVorlage_Gourmet_WirUeberUns = Image.FromFile(File_Vorlage_Gourmet_WirUeberUns);
string Base64StringVorlage_Gourmet_WirUeberUns = ZF.BitmapToBase64(ImageVorlage_Gourmet_WirUeberUns);
GV.Vorlage_Gourmet_WirUeberUns = Base64StringVorlage_Gourmet_WirUeberUns;
}
catch (Exception e)
{
GV.bFehler_Ini = true;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("!! Fehler beim Lesen von MatrixGuide.ini !!");
Console.WriteLine("Message:" + e.Message);
if (!(e.InnerException != null))
{
Console.WriteLine("InnerException: " + e.InnerException.ToString());
}
Console.ForegroundColor = ConsoleColor.White;
}
string cTimeStamp = System.DateTime.Now.ToShortDateString() + " / " + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString();
string cKonsolenausgabe = "Starten von MatrixGuide - " + ZF.TimeStamp();
Console.WriteLine(cKonsolenausgabe);
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
;
}
---- End Update --------------
I work with asp.net core 2.2 and start the app as console application (kestrel) on our internet server.
A valid public cert is attached (.pfx, see configuration in appsettings.json below).
Problem:
- If I test the app internally and externally over the internet, I cannot comprehend any problem (anything works as expected).
- I have no problems to start the app.
- But sporadically (not to comprehend, not to provocate), I have error messages (exceptions to crashes) in the console (see below).
- when the crashes occur, they usually occur multiple times (mostly > 10 times) - unfortunately, I cannot say in what time frame (as no timestamp’s are wrote to the console).
- Further, I often (strangeways) have a lot of empty lines on the console after the error messages).
Appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
,
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5001"
},
"HttpsInlineCertFile": {
"Url": "https://192.168.3.3",
"Protocols": "Http1AndHttp2",
"Certificate": {
"Path": "./certificate_2021.pfx",
"Password": "Passwort",
"AllowInvalid": "true"
}
}
}
}
}
Note: The cert is not imported in the cert-store of the server (as I think, this is not needed).
I have searched the internet for days now and have not found any hint, that drives me in the right direction.
Thanks for any help/hint in which direction, I have to search or how to provocate the crash.
Exception:
Fail: Microsoft.AspNetCore.Server.Kestrel[0]
Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.Net.InternalException: Exception of type 'System.Net.InternalException' was thrown.
at System.Net.SecurityStatusAdapterPal.GetSecurityStatusPalFromInterop(SECURITY_STATUS win32SecurityStatus, Boolean attachException)
at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output)
at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__51_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)