Npgsql is the .NET data provider for Postgresql. It allows any program developed for .NET framework to access a Postgresql database server. It is implemented in 100% C# code. Postgresql versions since 9.0 are officially supported, others may work.
@FerrariF70 check out the docs on connection string parameters: https://www.npgsql.org/doc/connection-string-parameters.html
this my connection string, but I get message in log that a valid client certificate is required to connect but I connected with this certificate in past.@"Server=127.0.0.1; port=5432; database=constructioncore; Username=postgres; TrustServerCertificate=false; PGSSLCERT=d:\certificates\server.crt; SslMode=Require; PGSSLKEY=d:\certificates\server.key; PGSSLROOTCERT=d:\certificates\root.crt;";
I received this message a valid client certificate is required to connect, when I provided certificate like this form
services.AddDbContext<CorpDbContext>(options => options.UseNpgsql(connectionString, builder =>
{
builder.RemoteCertificateValidationCallback((s, c, ch, sslPolicyErrors) =>
{
if (sslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
return true;
});
builder.ProvideClientCertificatesCallback(clientCerts =>
{
var clientcertPath = @"d:\certificates\server.crt";
var cert = new X509Certificate2(clientcertPath);
clientCerts.Add(cert);
});
}
But when I changed to this code I was able connect to database
services.AddDbContext<CorpDbContext>(options => options.UseNpgsql(connectionString, builder =>
{
builder.RemoteCertificateValidationCallback((s, c, ch, sslPolicyErrors) =>
{
if (sslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
return true;
});
builder.ProvideClientCertificatesCallback(clientCerts =>
{
var clientcertPath = @"d:\certificates\server.pfx";
var cert = new X509Certificate2(clientcertPath,"qwerty");
clientCerts.Add(cert);
});
}
foreach (var entry in filtered)
{
switch (entry.State)
{
case EntityState.Added:
//entry.CurrentValues["IsDeleted"] = false;
((EntityAudit)entry.Entity).IsDeleted = false;
break;
case EntityState.Deleted:
entry.State = EntityState.Modified;
//entry.CurrentValues["IsDeleted"] = true;
((EntityAudit)entry.Entity).IsDeleted = true;
break;
}
}
Narrowed it down to that it happens for geometries produced by WKTReader.. even if the input WKT has no third ordinate..
@bjornharrtell I know I'm late, but you need to tell the WKTReader to not allow for old NTS coordinate syntax (reader.IsOldNtsCoordinateSyntaxAllowed = false;
).
Hello, what is the mean Npgsql.PostgresException (0x80004005): 28000: connection requires a valid client certificate. I deploy my app on linux and I get this exception when try retrieve data from database. But when I connect with that certificate to database from terminal with psql "..." this authentication is pass over. Where is the problem? please help me, any tips.
As I see from this npgsql/npgsql#1721, the problem has existed for a long time, that everything seems very strange, either they don’t know how to solve it or they don’t want to. @roji I want to hear what's going on about this problem?
timestamp without time zone
but when i try to store DateTime.Now in it, I get Cannot write DateTime with Kind=Local to PostgreSQL type 'timestamp with time zone'
why does it give me a error for timestamp with time zone
when I'm using without?
timestamp without time zone
(remember that timestamp with time zone
is the default for .NET DateTime!). See https://github.com/npgsql/efcore.pg/issues/2128#issuecomment-983404118 for more info, if that doesn't help please open an issue with a repro and I'll try to help.
NpgsqlException (0x80004005): Exception while connecting
). I updated to Npgsql 6.0 and the errors changed to Npgsql.NpgsqlException (0x80004005): Exception while reading from stream
. This starts happening at around 400 queries per second. how can I fix this?
timestamp without time zone
column in fact already contains UTC timestamps, set TimeZone to UTC as explained in the link above.