Re: PostgreSQL 9.3.5 - Enable SSL

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: PostgreSQL 9.3.5 - Enable SSL
Дата
Msg-id A737B7A37273E048B164557ADEF4A58B53828A3A@ntex2010a.host.magwien.gv.at
обсуждение исходный текст
Ответ на Re: PostgreSQL 9.3.5 - Enable SSL  (<shyamkant.dhamke@wipro.com>)
Список pgsql-admin
shyamkant.dhamke@wipro.com wrote:
> I need sample C program ( running on Unix )  to connect to PostgreSQL 9.3.5 (SSL Enabled) database.

#include <stdio.h>
#include <libpq-fe.h>

int main(int argc, char **argv) {
    PGconn *conn;

    conn = PQconnectdb("host=... port=... dbname=... user=... password=...");
    if (conn == NULL) {
        fprintf(stderr, "Out of memory.\n");
        return 1;
    }
    if (PQstatus(conn) != CONNECTION_OK) {
        fprintf(stderr, PQerrorMessage(conn));
        PQfinish(conn);
        return 1;
    }

    PQfinish(conn);
    return 0;
}


Essentially, there's nothing special to do in the C code.

You have to have the server set up for SSL (ssl=on) and the certificate and key in place.
On the client side, you can add "sslmode=require" as connection option to make sure that
no unencrypted connection is attempted.

Yours,
Laurenz Albe

В списке pgsql-admin по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_dump fails on temp tables
Следующее
От: "drum.lucas@gmail.com"
Дата:
Сообщение: [INFO] - vm.dirty_ratio/background_ratio