Home
> Uncategorized > Using #Postgres from .NET Core
Using #Postgres from .NET Core

This little “Hello World” of Postgres is a simple application in .NET that accesses the CRT.SH certifiate database to list all known Certificate Authorities.
The CRT.SH database is open to all clients thanks to Sectigo.
TL;DR; Here is the Github repo https://github.com/infiniteloopltd/HelloWorldPostgres2
using System;
using Npgsql; // Install-Package Npgsql -Version 4.1.3.1
namespace HelloPostgres
{
class Program
{
static void Main(string[] args)
{
const string connString = "Host=crt.sh;Username=guest;Password=certwatch;Database=certwatch";
var conn = new NpgsqlConnection(connString);
conn.Open();
// List all certificate authorities
var cmd = new NpgsqlCommand("select name from ca", conn);
var reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["name"]);
}
conn.Close();
Console.ReadLine();
}
}
}
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback