SSL problem when database user requires X509
Posted: Mon 30 Aug 2010 22:46
We have a MySQL 5.0.86 database setup for SSL. The database user that we have is setup with "REQUIRE X509" option. From the client side, we are constructing the connection string using the certificate and the key files in pem format generated using OpenSSL.
The driver version is CoreLab.MySql v3.55.17
The connection string looks like this:
User Id=user;Password=pwd;Host=dbHost;Port=3306;Database=dbName;Direct=True;Unicode=True;Protocol=Ssl;Pooling=True;Connection Lifetime=1800;SSL CA Cert="file://C:\newcerts\ca-cert.pem";SSL Cert="file://C:\newcerts\client-cert.pem";SSL Key="file://C:\newcerts\client-key.pem";
We are able to make a connection from the windows desktop client (c# .net 3.5) but we cannot connect to the database from the web application.
If we run as the default process identity ASPNET (or Network Service), we receive the following exception:
CryptographicException: Couldn't acquire crypto service provider context.
at CoreLab.Cryptography.e.a(Int32& A_0, String A_1)
at CoreLab.Cryptography.e.a()
at CoreLab.Security.j.a(Byte[] A_0)
at CoreLab.Security.j.f(String A_0)
at CoreLab.MySql.j.a(String A_0, String A_1)
at CoreLab.MySql.b.a(String A_0, String A_1, String A_2, String A_3, Int32 A_4, String A_5, Int32 A_6, SshOptions A_7, SslOptions A_8)
at CoreLab.MySql.MySqlInternalConnection.Connect(String userId, String password, String host, String database, Int32 port, Int32 connectionTimeout, MySqlProtocol protocol, Boolean compress)
at CoreLab.MySql.MySqlInternalConnection..ctor(ac connectionOptions)
at CoreLab.MySql.a7.a(DbConnectionOptions A_0, Object A_1, DbConnectionBase A_2)
at CoreLab.Common.DbConnectionFactory.a(DbConnectionPool A_0, DbConnectionOptions A_1)
at CoreLab.Common.DbConnectionPoolGroup.c(DbConnectionPool A_0)
at CoreLab.Common.DbConnectionPool.a()
at CoreLab.Common.DbConnectionPool.GetObject()
at CoreLab.Common.DbConnectionFactory.a(DbConnectionBase A_0)
at CoreLab.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at CoreLab.Common.DbConnectionBase.Open()
at CoreLab.MySql.MySqlConnection.Open()
If we run the application as a higher privileged user (Local System), we get the following exception:
Lost connection to MySQL server during query
at CoreLab.MySql.a0.c(Byte[] A_0, Int32 A_1, Int32 A_2)
at CoreLab.MySql.a0.j()
at CoreLab.MySql.b.a(String A_0, String A_1, String A_2, String A_3, Int32 A_4, String A_5, Int32 A_6, SshOptions A_7, SslOptions A_8)
at CoreLab.MySql.MySqlInternalConnection.Connect(String userId, String password, String host, String database, Int32 port, Int32 connectionTimeout, MySqlProtocol protocol, Boolean compress)
at CoreLab.MySql.MySqlInternalConnection..ctor(ac connectionOptions)
at CoreLab.MySql.a7.a(DbConnectionOptions A_0, Object A_1, DbConnectionBase A_2)
at CoreLab.Common.DbConnectionFactory.a(DbConnectionPool A_0, DbConnectionOptions A_1)
at CoreLab.Common.DbConnectionPoolGroup.c(DbConnectionPool A_0)
at CoreLab.Common.DbConnectionPool.a()
at CoreLab.Common.DbConnectionPool.GetObject()
at CoreLab.Common.DbConnectionFactory.a(DbConnectionBase A_0)
at CoreLab.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at CoreLab.Common.DbConnectionBase.Open()
at CoreLab.MySql.MySqlConnection.Open()
I have tried to grant "Everyone" access to the certificate files (including client-key.pem) and still it does not work but if we run the web process as a user who is an admin on the machine, it works.
Please let me know what kind of access is required by the Corelab drivers when trying to read and process the certificate key so that we can fix it.
Thanks.
The driver version is CoreLab.MySql v3.55.17
The connection string looks like this:
User Id=user;Password=pwd;Host=dbHost;Port=3306;Database=dbName;Direct=True;Unicode=True;Protocol=Ssl;Pooling=True;Connection Lifetime=1800;SSL CA Cert="file://C:\newcerts\ca-cert.pem";SSL Cert="file://C:\newcerts\client-cert.pem";SSL Key="file://C:\newcerts\client-key.pem";
We are able to make a connection from the windows desktop client (c# .net 3.5) but we cannot connect to the database from the web application.
If we run as the default process identity ASPNET (or Network Service), we receive the following exception:
CryptographicException: Couldn't acquire crypto service provider context.
at CoreLab.Cryptography.e.a(Int32& A_0, String A_1)
at CoreLab.Cryptography.e.a()
at CoreLab.Security.j.a(Byte[] A_0)
at CoreLab.Security.j.f(String A_0)
at CoreLab.MySql.j.a(String A_0, String A_1)
at CoreLab.MySql.b.a(String A_0, String A_1, String A_2, String A_3, Int32 A_4, String A_5, Int32 A_6, SshOptions A_7, SslOptions A_8)
at CoreLab.MySql.MySqlInternalConnection.Connect(String userId, String password, String host, String database, Int32 port, Int32 connectionTimeout, MySqlProtocol protocol, Boolean compress)
at CoreLab.MySql.MySqlInternalConnection..ctor(ac connectionOptions)
at CoreLab.MySql.a7.a(DbConnectionOptions A_0, Object A_1, DbConnectionBase A_2)
at CoreLab.Common.DbConnectionFactory.a(DbConnectionPool A_0, DbConnectionOptions A_1)
at CoreLab.Common.DbConnectionPoolGroup.c(DbConnectionPool A_0)
at CoreLab.Common.DbConnectionPool.a()
at CoreLab.Common.DbConnectionPool.GetObject()
at CoreLab.Common.DbConnectionFactory.a(DbConnectionBase A_0)
at CoreLab.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at CoreLab.Common.DbConnectionBase.Open()
at CoreLab.MySql.MySqlConnection.Open()
If we run the application as a higher privileged user (Local System), we get the following exception:
Lost connection to MySQL server during query
at CoreLab.MySql.a0.c(Byte[] A_0, Int32 A_1, Int32 A_2)
at CoreLab.MySql.a0.j()
at CoreLab.MySql.b.a(String A_0, String A_1, String A_2, String A_3, Int32 A_4, String A_5, Int32 A_6, SshOptions A_7, SslOptions A_8)
at CoreLab.MySql.MySqlInternalConnection.Connect(String userId, String password, String host, String database, Int32 port, Int32 connectionTimeout, MySqlProtocol protocol, Boolean compress)
at CoreLab.MySql.MySqlInternalConnection..ctor(ac connectionOptions)
at CoreLab.MySql.a7.a(DbConnectionOptions A_0, Object A_1, DbConnectionBase A_2)
at CoreLab.Common.DbConnectionFactory.a(DbConnectionPool A_0, DbConnectionOptions A_1)
at CoreLab.Common.DbConnectionPoolGroup.c(DbConnectionPool A_0)
at CoreLab.Common.DbConnectionPool.a()
at CoreLab.Common.DbConnectionPool.GetObject()
at CoreLab.Common.DbConnectionFactory.a(DbConnectionBase A_0)
at CoreLab.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at CoreLab.Common.DbConnectionBase.Open()
at CoreLab.MySql.MySqlConnection.Open()
I have tried to grant "Everyone" access to the certificate files (including client-key.pem) and still it does not work but if we run the web process as a user who is an admin on the machine, it works.
Please let me know what kind of access is required by the Corelab drivers when trying to read and process the certificate key so that we can fix it.
Thanks.