11
11
*
12
12
*
13
13
* 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 $
15
15
*
16
16
* NOTES
17
17
* The client *requires* a valid server certificate. Since
@@ -312,7 +312,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
312
312
printfPQExpBuffer (& conn -> errorMessage ,
313
313
libpq_gettext ("SSL SYSCALL error: EOF detected\n" ));
314
314
315
- SOCK_ERRNO = ECONNRESET ;
315
+ SOCK_ERRNO_SET ( ECONNRESET ) ;
316
316
n = -1 ;
317
317
}
318
318
break ;
@@ -322,7 +322,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
322
322
libpq_gettext ("SSL error: %s\n" ),SSLerrmessage ());
323
323
/* fall through */
324
324
case SSL_ERROR_ZERO_RETURN :
325
- SOCK_ERRNO = ECONNRESET ;
325
+ SOCK_ERRNO_SET ( ECONNRESET ) ;
326
326
n = -1 ;
327
327
break ;
328
328
default :
@@ -383,7 +383,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
383
383
{
384
384
printfPQExpBuffer (& conn -> errorMessage ,
385
385
libpq_gettext ("SSL SYSCALL error: EOF detected\n" ));
386
- SOCK_ERRNO = ECONNRESET ;
386
+ SOCK_ERRNO_SET ( ECONNRESET ) ;
387
387
n = -1 ;
388
388
}
389
389
break ;
@@ -393,7 +393,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
393
393
libpq_gettext ("SSL error: %s\n" ),SSLerrmessage ());
394
394
/* fall through */
395
395
case SSL_ERROR_ZERO_RETURN :
396
- SOCK_ERRNO = ECONNRESET ;
396
+ SOCK_ERRNO_SET ( ECONNRESET ) ;
397
397
n = -1 ;
398
398
break ;
399
399
default :
@@ -544,6 +544,9 @@ verify_peer(PGconn *conn)
544
544
static DH *
545
545
load_dh_file (int keylength )
546
546
{
547
+ #ifdef WIN32
548
+ return NULL ;
549
+ #else
547
550
char pwdbuf [BUFSIZ ];
548
551
struct passwd pwdstr ;
549
552
struct passwd * pwd = NULL ;
@@ -558,6 +561,7 @@ load_dh_file(int keylength)
558
561
/* attempt to open file. It's not an error if it doesn't exist. */
559
562
snprintf (fnbuf ,sizeof fnbuf ,"%s/.postgresql/dh%d.pem" ,
560
563
pwd -> pw_dir ,keylength );
564
+
561
565
if ((fp = fopen (fnbuf ,"r" ))== NULL )
562
566
return NULL ;
563
567
@@ -583,6 +587,7 @@ load_dh_file(int keylength)
583
587
}
584
588
585
589
return dh ;
590
+ #endif
586
591
}
587
592
588
593
/*
@@ -686,6 +691,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength)
686
691
static int
687
692
client_cert_cb (SSL * ssl ,X509 * * x509 ,EVP_PKEY * * pkey )
688
693
{
694
+ #ifdef WIN32
695
+ return 0 ;
696
+ #else
689
697
char pwdbuf [BUFSIZ ];
690
698
struct passwd pwdstr ;
691
699
struct passwd * pwd = NULL ;
@@ -785,6 +793,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
785
793
}
786
794
787
795
return 1 ;
796
+ #endif
788
797
}
789
798
790
799
/*
@@ -793,11 +802,13 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
793
802
static int
794
803
initialize_SSL (PGconn * conn )
795
804
{
805
+ #ifndef WIN32
796
806
struct stat buf ;
797
807
char pwdbuf [BUFSIZ ];
798
808
struct passwd pwdstr ;
799
809
struct passwd * pwd = NULL ;
800
810
char fnbuf [2048 ];
811
+ #endif
801
812
802
813
if (!SSL_context )
803
814
{
@@ -813,6 +824,7 @@ initialize_SSL(PGconn *conn)
813
824
}
814
825
}
815
826
827
+ #ifndef WIN32
816
828
if (pqGetpwuid (getuid (),& pwdstr ,pwdbuf ,sizeof (pwdbuf ),& pwd )== 0 )
817
829
{
818
830
snprintf (fnbuf ,sizeof fnbuf ,"%s/.postgresql/root.crt" ,
@@ -849,6 +861,7 @@ initialize_SSL(PGconn *conn)
849
861
850
862
/* set up mechanism to provide client certificate, if available */
851
863
SSL_CTX_set_client_cert_cb (SSL_context ,client_cert_cb );
864
+ #endif
852
865
853
866
return 0 ;
854
867
}