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)
312312 printfPQExpBuffer (& conn -> errorMessage ,
313313 libpq_gettext ("SSL SYSCALL error: EOF detected\n" ));
314314
315- SOCK_ERRNO = ECONNRESET ;
315+ SOCK_ERRNO_SET ( ECONNRESET ) ;
316316 n = -1 ;
317317 }
318318 break ;
@@ -322,7 +322,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
322322 libpq_gettext ("SSL error: %s\n" ), SSLerrmessage ());
323323 /* fall through */
324324 case SSL_ERROR_ZERO_RETURN :
325- SOCK_ERRNO = ECONNRESET ;
325+ SOCK_ERRNO_SET ( ECONNRESET ) ;
326326 n = -1 ;
327327 break ;
328328 default :
@@ -383,7 +383,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
383383 {
384384 printfPQExpBuffer (& conn -> errorMessage ,
385385 libpq_gettext ("SSL SYSCALL error: EOF detected\n" ));
386- SOCK_ERRNO = ECONNRESET ;
386+ SOCK_ERRNO_SET ( ECONNRESET ) ;
387387 n = -1 ;
388388 }
389389 break ;
@@ -393,7 +393,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
393393 libpq_gettext ("SSL error: %s\n" ), SSLerrmessage ());
394394 /* fall through */
395395 case SSL_ERROR_ZERO_RETURN :
396- SOCK_ERRNO = ECONNRESET ;
396+ SOCK_ERRNO_SET ( ECONNRESET ) ;
397397 n = -1 ;
398398 break ;
399399 default :
@@ -544,6 +544,9 @@ verify_peer(PGconn *conn)
544544static DH *
545545load_dh_file (int keylength )
546546{
547+ #ifdef WIN32
548+ return NULL ;
549+ #else
547550 char pwdbuf [BUFSIZ ];
548551 struct passwd pwdstr ;
549552 struct 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. */
559562 snprintf (fnbuf , sizeof fnbuf , "%s/.postgresql/dh%d.pem" ,
560563 pwd -> pw_dir , keylength );
564+
561565 if ((fp = fopen (fnbuf , "r" )) == NULL )
562566 return NULL ;
563567
@@ -583,6 +587,7 @@ load_dh_file(int keylength)
583587 }
584588
585589 return 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
689697 char pwdbuf [BUFSIZ ];
690698 struct passwd pwdstr ;
691699 struct passwd * pwd = NULL ;
@@ -785,6 +793,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
785793 }
786794
787795 return 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
796806 struct stat buf ;
797807 char pwdbuf [BUFSIZ ];
798808 struct passwd pwdstr ;
799809 struct passwd * pwd = NULL ;
800810 char fnbuf [2048 ];
811+ #endif
801812
802813 if (!SSL_context )
803814 {
@@ -813,6 +824,7 @@ initialize_SSL(PGconn *conn)
813824 }
814825 }
815826
827+ #ifndef WIN32
816828 if (pqGetpwuid (getuid (), & pwdstr , pwdbuf , sizeof (pwdbuf ), & pwd ) == 0 )
817829 {
818830 snprintf (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 */
851863 SSL_CTX_set_client_cert_cb (SSL_context , client_cert_cb );
864+ #endif
852865
853866 return 0 ;
854867}
0 commit comments