question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specified SSL Protocol Type is not Valid

See original GitHub issue

I am using an application that is imbedded within Autodesk Revit levering their open API. I have worked inside this context for a couple years and connected to other industry DB platform without any issues.

1. I have the application that makes a call to another dll (pgRDG)

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace RDG_Revit_2022.Testing
{
	[Transaction(TransactionMode.Manual)]
	class Test : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIApplication uiapp = commandData.Application;
			Document doc = uiapp.ActiveUIDocument.Document;

			//This is the external reference call
			pg.RDG.Connection.Testing();
			return Result.Succeeded;
		}
	}
}

2. Then here is the Testing() method.

using System;
using System.Windows;
using Npgsql;

namespace pgRDG
{
	public class Connection
    {
        public static void Testing()
		{
			string ConnString = "Server=name.postgres.database.azure.com;Database=dbName;Port=5432;User Id=uid;Password=pw;Trust Server Certificate=true;Ssl Mode=Require";
			using(NpgsqlConnection conn = new NpgsqlConnection(ConnString))
			{
				try
				{
					conn.Open();
					NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM tableName", conn);
					NpgsqlDataReader reader = cmd.ExecuteReader();
					while(reader.Read())
					{
						MessageBox.Show(reader.GetString(reader.GetOrdinal("command")));
					}
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
			}
		}
    }
}

The issue

  1. When I run this I receive the following error: image

If I run this exact same code from a desktop application it connects fine, but always produces this error within the Revit context.

I have also created a request on the Autodesk forums thinking someone there may have an idea as well. https://forums.autodesk.com/t5/revit-api-forum/revit-2022-environment-preventing-ssl-handshake-with-postgresql/td-p/10304990

Further technical details

Npgsql version: 6.0.0-preview2 PostgreSQL version: Azure version 11 Operating system: Window 10 x64 - Visual Studio Pro 19 - v16.8.4 Autodesk Revit 2022

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
TorsionToolscommented, May 21, 2021

I appreciate you all working on this. Preview3 (6.0.0) was the first install that got past the missing reference for Text.JSON but it was throwing this SSL Protocol error for me. I have downloaded the latest unstable version (20210521T094529 which doesn’t throw the SSL Protocol warning or at least doesn’t get there because its back missing references for Text.JSON 5.0.0.0 even with redirects for 5.0.0.2.

1reaction
vonzshikcommented, May 13, 2021

However, another option is to do runtime detection and select SslProtocol as a function of that (or even conditional compilation for .NET Standard 2.0). I still think it’s better for us to specify SslProtocol.None, and it would be a shame to not do that because of .NET Framework…

Sure, works for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - ServicePointManager.SecurityProtocol is not ...
ArgumentException : The specified value is not valid in the 'SslProtocolType' enumeration. Parameter name: sslProtocolType.
Read more >
Support for TLS System Default Versions included in the . ...
System.ArgumentException : The specified value is not valid in the 'SslProtocolType' enumeration. Parameter name: sslProtocolType. Note For SslStream only, a ...
Read more >
ERR_SSL_PROTOCOL_ERROR: 3 Easy Steps to Resolve It
The reason is that the certificate will have an incorrect associated domain name. In this case, try uninstalling the SSL and redo the ......
Read more >
Invalid SSL certificate: how to solve
An invalid SSL certificate warning can cause users to leave the site (and never return). It is important to understand the possible causes ......
Read more >
How do I change the default SSL/TLS protocol my Java™ ...
The https.protocols is only valid if the Client Application us using HttpsURLConnection class or URL.openStream() operations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found