System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation

432 Views Asked by At

I've recently installed stackify on my dev API server and I have this error coming in on the stackify error dashboard but I cannot reproduce the error. I believe there is an error logged for almost every request made to the API, eventhough all the requests are OK(200) and none have responded with ServerError(5XX).

This is the error message:

System.Security.Cryptography.CryptographicException: System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation. at System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.HomogenizeErrors(Func`2 func, Byte[] input)

Error Document:

{
  "id": "1266b838-a261-4bde-9220-ff7993d72c0e",
  "env": "dev",
  "host": "raidsrv3",
  "appname": "environment.appname.com",
  "version": null,
  "apploc": "D:\\StageApplications\\environment.appname.com",
  "message": "System.NullReferenceException: Object reference not set to an instance of an object.\r\nSystem.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.\r\n  at lambda_method(Closure , LoginViewModel )\r\n",
  "json": null,
  "jsonPreview": null,
  "thread": "40",
  "threadOs": null,
  "transid": "7af3de61-9bf1-43d8-b60c-ff9850a35490",
  "timestamp": "2021-01-20T14:21:41.247Z",
  "inserted": "2021-01-20T14:22:11.8261135Z",
  "level": "ERROR",
  "logType": "app-dotnet",
  "logger": null,
  "urlRoute": "Home.Login",
  "urlFull": null,
  "sourcemethod": "lambda_method(Closure , LoginViewModel )",
  "sourceline": null,
  "stackify": {
    "CdWebAppId": null,
    "CdId": 1,
    "CdAppId": 215,
    "Error": 1,
    "WebLogUrlId": null,
    "Queued": "2021-01-20T14:21:47.0806791Z",
    "Tooksecs": 24.745,
    "QueuedPartition": "Jan201400p1",
    "Trace": null,
    "FromApm": null,
    "Order": 1,
    "InvalidEpochStr": null,
    "IsWebLog": false,
    "AppNameId": "23f72352-2d5a-eb11-a607-0003ffcfb91b",
    "AppEnvId": "43f72352-2d5a-eb11-a607-0003ffcfb91b",
    "EnvId": 2,
    "Timestamp1M": "2021-01-20T14:21:00Z",
    "Timestamp5M": "2021-01-20T14:20:00Z",
    "Timestamp1H": "2021-01-20T14:00:00Z",
    "Timestamp1D": "2021-01-20T00:00:00Z",
    "IsProd": true,
    "Expiration1D": "2021-02-05T00:00:00Z",
    "DeploymentId": null
  },
  "error": {
    "StackifyErrorID": "1266b838-a261-4bde-9220-ff7993d72c0e",
    "OccurredEpochMillis": 1611152501247,
    "Error": {
      "InnerError": null,
      "StackTrace": [
        {
          "LineNum": null,
          "Method": "lambda_method(Closure , LoginViewModel )",
          "CodeFileName": null
        }
      ],
      "Message": "System.NullReferenceException: Object reference not set to an instance of an object.",
      "ErrorType": "System.NullReferenceException",
      "ErrorTypeCode": "-2147467261",
      "Data": null,
      "SourceMethod": "lambda_method(Closure , LoginViewModel )"
    },
    "data": {},
    "EnvironmentDetail": {
      "DeviceName": "RAIDSRV3",
      "AppLocation": "D:\\StageApplications\\environment.appname.com",
      "AppName": "environment.appname.com",
      "WebAppID": null,
      "ConfiguredAppName": null,
      "ConfiguredEnvironmentName": null,
      "ConfiguredLocationName": null,
      "IsAzureWorkerRole": false
    },
    "WebRequestDetail": {
      "UserIPAddress": null,
      "HttpMethod": "GET",
      "RequestProtocol": null,
      "WebLogUrl": "Home.Login",
      "RequestDomain": "environment.appname.com",
      "ReportingUrl": "Home.Login",
      "UrlKey": "get-home.login",
      "RequestUrl": "https://environment.appname.com/",
      "RequestUrlRoot": null,
      "RequestRoute": null,
      "ReferralUrl": null,
      "UserAgent": null,
      "Headers": {},
      "Cookies": {},
      "QueryString": {},
      "PostData": {},
      "SessionData": {},
      "PostDataRaw": null,
      "MvcAction": null,
      "MvcController": null,
      "MvcArea": null
    },
    "ApiClient": {
      "Name": null,
      "Platform": ".net"
    },
    "ServerVariables": {},
    "CustomerName": null,
    "UserName": null,
    "errorGroupId": "b772fbd6-db5a-eb11-a607-0003ffcfb91b",
    "errorGroupInstanceId": "bf72fbd6-db5a-eb11-a607-0003ffcfb91b",
    "displayMethodId": "d65c87ef-ca5a-eb11-a607-0003ffcfb91b",
    "errorSourceMethodId": "d65c87ef-ca5a-eb11-a607-0003ffcfb91b",
    "errorTypeMessageId": "2-df28da1c-715a-eb11-a607-0003ffcfb91b-0e8ec107143a2e3d04bfee99e49c20a5",
    "errorUniqueId": "d75c87ef-ca5a-eb11-a607-0003ffcfb91b",
    "errorPlatformTypeId": 2,
    "errorStateId": 0,
    "errorTypeId": "df28da1c-715a-eb11-a607-0003ffcfb91b",
    "message": "System.NullReferenceException: Object reference not set to an instance of an object.",
    "errorType": "System.NullReferenceException",
    "errorTypeClass": "NullReferenceException",
    "errorTypeCode": "-2147467261",
    "sourceMethodName": "lambda_method(Closure , LoginViewModel )",
    "sourceMethodShort": "lambda_method(Closure , LoginViewModel )",
    "errorGroupCreatedUtc": "2021-01-20T04:55:18.767",
    "displayMethodName": "lambda_method(Closure , LoginViewModel )",
    "displayMethodShort": "lambda_method(Closure , LoginViewModel )",
    "stackTraceHash": "858F2DB7DA4C81444B39BA60C9CC5B65",
    "stackTrace": "System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.\n\tat lambda_method(Closure , LoginViewModel )\n",
    "appended": "2021-01-20T14:22:22.5880117Z"
  },
  "winevent": null,
  "weblog": null,
  "tag": [
    "fromapm"
  ],
  "container": null,
  "kubernetes": null
}

I have searched all over but I can't find an explanation for this error.

Here's some background info about my dev environment:

  • The API is .net Framework 4.7.2
  • I updated all the nuget packages and libries to their latest supported version
  • The machine key is already configured and I have verified the same key exists in both API servers web.config files. eg: <machineKey validationKey="***" decryptionKey="***" />
  • API is deployed on 2 servers, with nginx inbetween the client and the servers.
  • Ocotopus Deploy is used to deploy the API
  • DFS is used to sync the application files from the main server to the sister server

Any help will be greatly appreciated!

1

There are 1 best solutions below

0
On

Turns out this exception that was being caught by stackify was a First Chance exception that is handled inside the .net framework.

More on first chance exceptions at this answer here

And if you're like me and your organization is concerned about all the exceptions being captured by Stackify, you can go to the environment settings > Editing Environment > Automatic collection & viewing of app errors via APM and change the setting from Upload all errors to error module to Upload unhandled errors to error module.

enter image description here

That will make sure that only unhandled exceptions bubble up into stackify.