1111 *
1212 *
1313 * IDENTIFICATION
14- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.79 2006/04/27 14: 02:36 momjian Exp $
14+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.80 2006/05/06 02:24:39 momjian Exp $
1515 *
1616 * NOTES
1717 * [ Most of these notes are wrong/obsolete, but perhaps not all ]
125125#define USER_CERT_FILE ".postgresql/postgresql.crt"
126126#define USER_KEY_FILE ".postgresql/postgresql.key"
127127#define ROOT_CERT_FILE ".postgresql/root.crt"
128+ #define ROOT_CRL_FILE ".postgresql/root.crl"
128129#else
129130/* On Windows, the "home" directory is already PostgreSQL-specific */
130131#define USER_CERT_FILE "postgresql.crt"
131132#define USER_KEY_FILE "postgresql.key"
132133#define ROOT_CERT_FILE "root.crt"
134+ #define ROOT_CRL_FILE "root.crl"
133135#endif
134136
135137#ifdef NOT_USED
@@ -784,6 +786,8 @@ initialize_SSL(PGconn *conn)
784786snprintf (fnbuf ,sizeof (fnbuf ),"%s/%s" ,homedir ,ROOT_CERT_FILE );
785787if (stat (fnbuf ,& buf )== 0 )
786788{
789+ X509_STORE * cvstore ;
790+
787791if (!SSL_CTX_load_verify_locations (SSL_context ,fnbuf ,NULL ))
788792{
789793char * err = SSLerrmessage ();
@@ -795,6 +799,28 @@ initialize_SSL(PGconn *conn)
795799return -1 ;
796800}
797801
802+ if ((cvstore = SSL_CTX_get_cert_store (SSL_context ))!= NULL )
803+ {
804+ /* setting the flags to check against the complete CRL chain */
805+ if (X509_STORE_load_locations (cvstore ,ROOT_CRL_FILE ,NULL )!= 0 )
806+ /* OpenSSL 0.96 does not support X509_V_FLAG_CRL_CHECK */
807+ #ifdef X509_V_FLAG_CRL_CHECK
808+ X509_STORE_set_flags (cvstore ,
809+ X509_V_FLAG_CRL_CHECK |X509_V_FLAG_CRL_CHECK_ALL );
810+ /* if not found, silently ignore; we do not require CRL */
811+ #else
812+ {
813+ char * err = SSLerrmessage ();
814+
815+ printfPQExpBuffer (& conn -> errorMessage ,
816+ libpq_gettext ("Installed SSL library does not support CRL certificates, file \"%s\"\n" ),
817+ fnbuf );
818+ SSLerrfree (err );
819+ return -1 ;
820+ }
821+ #endif
822+ }
823+
798824SSL_CTX_set_verify (SSL_context ,SSL_VERIFY_PEER ,verify_cb );
799825}
800826}