1111 *
1212 *
1313 * IDENTIFICATION
14- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.29 2003/08/04 17:25:14 tgl Exp $
14+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.30 2003/09/05 02:08:36 momjian Exp $
1515 *
1616 * NOTES
1717 * The client *requires* a valid server certificate. Since
@@ -312,7 +312,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
312312printfPQExpBuffer (& conn -> errorMessage ,
313313libpq_gettext ("SSL SYSCALL error: EOF detected\n" ));
314314
315- SOCK_ERRNO = ECONNRESET ;
315+ SOCK_ERRNO_SET ( ECONNRESET ) ;
316316n = -1 ;
317317}
318318break ;
@@ -322,7 +322,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
322322libpq_gettext ("SSL error: %s\n" ),SSLerrmessage ());
323323/* fall through */
324324case SSL_ERROR_ZERO_RETURN :
325- SOCK_ERRNO = ECONNRESET ;
325+ SOCK_ERRNO_SET ( ECONNRESET ) ;
326326n = -1 ;
327327break ;
328328default :
@@ -383,7 +383,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
383383{
384384printfPQExpBuffer (& conn -> errorMessage ,
385385libpq_gettext ("SSL SYSCALL error: EOF detected\n" ));
386- SOCK_ERRNO = ECONNRESET ;
386+ SOCK_ERRNO_SET ( ECONNRESET ) ;
387387n = -1 ;
388388}
389389break ;
@@ -393,7 +393,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
393393libpq_gettext ("SSL error: %s\n" ),SSLerrmessage ());
394394/* fall through */
395395case SSL_ERROR_ZERO_RETURN :
396- SOCK_ERRNO = ECONNRESET ;
396+ SOCK_ERRNO_SET ( ECONNRESET ) ;
397397n = -1 ;
398398break ;
399399default :
@@ -544,6 +544,9 @@ verify_peer(PGconn *conn)
544544static DH *
545545load_dh_file (int keylength )
546546{
547+ #ifdef WIN32
548+ return NULL ;
549+ #else
547550char pwdbuf [BUFSIZ ];
548551struct passwd pwdstr ;
549552struct passwd * pwd = NULL ;
@@ -558,6 +561,7 @@ load_dh_file(int keylength)
558561/* attempt to open file. It's not an error if it doesn't exist. */
559562snprintf (fnbuf ,sizeof fnbuf ,"%s/.postgresql/dh%d.pem" ,
560563pwd -> pw_dir ,keylength );
564+
561565if ((fp = fopen (fnbuf ,"r" ))== NULL )
562566return NULL ;
563567
@@ -583,6 +587,7 @@ load_dh_file(int keylength)
583587}
584588
585589return dh ;
590+ #endif
586591}
587592
588593/*
@@ -686,6 +691,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength)
686691static int
687692client_cert_cb (SSL * ssl ,X509 * * x509 ,EVP_PKEY * * pkey )
688693{
694+ #ifdef WIN32
695+ return 0 ;
696+ #else
689697char pwdbuf [BUFSIZ ];
690698struct passwd pwdstr ;
691699struct passwd * pwd = NULL ;
@@ -785,6 +793,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
785793}
786794
787795return 1 ;
796+ #endif
788797}
789798
790799/*
@@ -793,11 +802,13 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
793802static int
794803initialize_SSL (PGconn * conn )
795804{
805+ #ifndef WIN32
796806struct stat buf ;
797807char pwdbuf [BUFSIZ ];
798808struct passwd pwdstr ;
799809struct passwd * pwd = NULL ;
800810char fnbuf [2048 ];
811+ #endif
801812
802813if (!SSL_context )
803814{
@@ -813,6 +824,7 @@ initialize_SSL(PGconn *conn)
813824}
814825}
815826
827+ #ifndef WIN32
816828if (pqGetpwuid (getuid (),& pwdstr ,pwdbuf ,sizeof (pwdbuf ),& pwd )== 0 )
817829{
818830snprintf (fnbuf ,sizeof fnbuf ,"%s/.postgresql/root.crt" ,
@@ -849,6 +861,7 @@ initialize_SSL(PGconn *conn)
849861
850862/* set up mechanism to provide client certificate, if available */
851863SSL_CTX_set_client_cert_cb (SSL_context ,client_cert_cb );
864+ #endif
852865
853866return 0 ;
854867}