mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Minor improvements to hack for old OpenSSL libraries: avoid unused
variable warning on Windows, improve comment.
This commit is contained in:
parent
a248dbc4f8
commit
fdbce93b85
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.98 2007/10/03 13:57:52 mha Exp $
|
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.99 2007/10/03 15:12:45 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* [ Most of these notes are wrong/obsolete, but perhaps not all ]
|
* [ Most of these notes are wrong/obsolete, but perhaps not all ]
|
||||||
@ -588,8 +588,8 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
|||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
struct stat buf2;
|
struct stat buf2;
|
||||||
#endif
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
#endif
|
||||||
char fnbuf[MAXPGPATH];
|
char fnbuf[MAXPGPATH];
|
||||||
BIO *bio;
|
BIO *bio;
|
||||||
PGconn *conn = (PGconn *) SSL_get_app_data(ssl);
|
PGconn *conn = (PGconn *) SSL_get_app_data(ssl);
|
||||||
@ -602,28 +602,33 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save OpenSSL error stack */
|
|
||||||
ERR_set_mark();
|
|
||||||
|
|
||||||
/* read the user certificate */
|
/* read the user certificate */
|
||||||
snprintf(fnbuf, sizeof(fnbuf), "%s/%s", homedir, USER_CERT_FILE);
|
snprintf(fnbuf, sizeof(fnbuf), "%s/%s", homedir, USER_CERT_FILE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OpenSSL <= 0.8.2 lacks error stack handling. Do a separate check
|
* OpenSSL <= 0.9.8 lacks error stack handling, which means it's likely
|
||||||
* for the existance of the file without using BIO functions to make
|
* to report wrong error messages if access to the cert file fails.
|
||||||
* it pick up the majority of the cases with the old versions.
|
* Do our own check for the readability of the file to catch the
|
||||||
|
* majority of such problems before OpenSSL gets involved.
|
||||||
*/
|
*/
|
||||||
#ifndef HAVE_ERR_SET_MARK
|
#ifndef HAVE_ERR_SET_MARK
|
||||||
if ((fp = fopen(fnbuf, "r")) == NULL)
|
{
|
||||||
|
FILE *fp2;
|
||||||
|
|
||||||
|
if ((fp2 = fopen(fnbuf, "r")) == NULL)
|
||||||
{
|
{
|
||||||
printfPQExpBuffer(&conn->errorMessage,
|
printfPQExpBuffer(&conn->errorMessage,
|
||||||
libpq_gettext("could not open certificate file \"%s\": %s\n"),
|
libpq_gettext("could not open certificate file \"%s\": %s\n"),
|
||||||
fnbuf, pqStrerror(errno, sebuf, sizeof(sebuf)));
|
fnbuf, pqStrerror(errno, sebuf, sizeof(sebuf)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp2);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* save OpenSSL error stack */
|
||||||
|
ERR_set_mark();
|
||||||
|
|
||||||
if ((bio = BIO_new_file(fnbuf, "r")) == NULL)
|
if ((bio = BIO_new_file(fnbuf, "r")) == NULL)
|
||||||
{
|
{
|
||||||
printfPQExpBuffer(&conn->errorMessage,
|
printfPQExpBuffer(&conn->errorMessage,
|
||||||
|
Loading…
Reference in New Issue
Block a user