oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
408 stars 190 forks source link

'Encrypt' is an invalid connection string attribute #287

Closed XtremeOwnageDotCom closed 1 year ago

XtremeOwnageDotCom commented 1 year ago

Not exactly sure what better place to put this- but, Anyone have an idea on this one?

There is nothing at all on my end specifying encryption for this.

My only clue, is this is related to the System.Data.Sql.Client changes which enabled Encrypt=true by default.

Using https://www.nuget.org/packages/Oracle.ManagedDataAccess v21.10.0 (Latest release)

    private OracleConnection getConnection(string SID)
    {
        string conString = $"User Id={this.creds.UserName};Password={this.creds.Password};Data Source={SID}";
        return new OracleConnection(conString);
    }
 message: 'Encrypt' is an invalid connection string attribute
     methodName: SetProperty
     nameSpace: OracleInternal.ConnectionPool
     source: Oracle.ManagedDataAccess
     stackTrace:    at OracleInternal.ConnectionPool.ConnectionString.SetProperty(String key, String value, String quotedValue, String originalKey, SecureString secPasswd, SecureString token)
   at OracleInternal.ConnectionPool.ConnectionString.Parse(OracleConnection con, String constr)
   at OracleInternal.ConnectionPool.ConnectionString..ctor(OracleConnection con, String constring, OracleCredential credential, OracleAccessToken accessToken, Boolean bIncludeOsUser)
   at OracleInternal.ConnectionPool.ConnectionString.GetCS(OracleConnection con, String constr, OracleCredential credential, OracleAccessToken accessToken, Boolean bCreateIfNotinCache, Boolean bIncludeOsUser)
   at Oracle.ManagedDataAccess.Client.OracleConnection.set_ConnectionString(String value)
   at Oracle.ManagedDataAccess.Client.OracleConnection..ctor(String connectionString)
   at mycode.getConnection(String SID) in redacted:line 22
alexkeh commented 1 year ago

You can try printing out what your ConnectionString value is to see whether its value is what you're expecting.

If you don't see the "Encrypt" string in there, you can also turn on ODP.NET tracing to see at a more granular level where Encrypt may be added.

OracleConfiguration.TraceFileLocation = @"C:\traces"; OracleConfiguration.TraceLevel = 7;

XtremeOwnageDotCom commented 1 year ago

Lets see....

    {
        const string path = @"D:\connString.txt";
        using (var file = new System.IO.StreamWriter(path, true))
        {
            string conString = $"User Id={this.creds.UserName};Password={this.creds.Password};Data Source={SID}";
            file.WriteLine("Before: " + conString);
            var conn = new OracleConnection(conString);
            #region Debugging Code

            file.WriteLine("After: " + conn.ConnectionString);

            #endregion
            return conn;
        }
Before: User Id=user;Password=;Encrypt=false;Data Source=sidgoeshere

That.... is interesting. Well, turns out, its something apparently on my end causing this.

@alexkeh Thanks for the idea of logging the connection string. Given, this issue is occuring on the before statement, I think its safe to say, its something odd going on my end.

XtremeOwnageDotCom commented 1 year ago

Turns out,

The password in the credentials manager, was set to, ;Encrypt=false

/facepalm.

Thanks for the assistance on this one.