aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-secure.c
Commit message (Collapse)AuthorAge
* Update copyrights for 2013Bruce Momjian2013-01-01
| | | | | Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
* Run pgindent on 9.2 source tree in preparation for first 9.3Bruce Momjian2012-06-10
| | | | commit-fest.
* Remove arbitrary limitation on length of common name in SSL certificates.Tom Lane2012-02-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both libpq and the backend would truncate a common name extracted from a certificate at 32 bytes. Replace that fixed-size buffer with dynamically allocated string so that there is no hard limit. While at it, remove the code for extracting peer_dn, which we weren't using for anything; and don't bother to store peer_cn longer than we need it in libpq. This limit was not so terribly unreasonable when the code was written, because we weren't using the result for anything critical, just logging it. But now that there are options for checking the common name against the server host name (in libpq) or using it as the user's name (in the server), this could result in undesirable failures. In the worst case it even seems possible to spoof a server name or user name, if the correct name is exactly 32 bytes and the attacker can persuade a trusted CA to issue a certificate in which that string is a prefix of the certificate's common name. (To exploit this for a server name, he'd also have to send the connection astray via phony DNS data or some such.) The case that this is a realistic security threat is a bit thin, but nonetheless we'll treat it as one. Back-patch to 8.4. Older releases contain the faulty code, but it's not a security problem because the common name wasn't used for anything interesting. Reported and patched by Heikki Linnakangas Security: CVE-2012-0867
* Update copyright notices for year 2012.Bruce Momjian2012-01-01
|
* Treat ENOTDIR as ENOENT when looking for client certificate fileMagnus Hagander2011-12-03
| | | | | | | | This makes it possible to use a libpq app with home directory set to /dev/null, for example - treating it the same as if the file doesn't exist (which it doesn't). Per bug #6302, reported by Diego Elio Petteno
* Add libpq connection option to disable SSL compressionMagnus Hagander2011-11-28
| | | | | | | This can be used to remove the overhead of SSL compression on fast networks. Laurenz Albe
* Fix previous patch so it also works if not USE_SSL (mea culpa).Tom Lane2011-07-24
| | | | | | On balance, the need to cover this case changes my mind in favor of pushing all error-message generation duties into the two fe-secure.c routines. So do it that way.
* Improve libpq's error reporting for SSL failures.Tom Lane2011-07-24
| | | | | | | | | | In many cases, pqsecure_read/pqsecure_write set up useful error messages, which were then overwritten with useless ones by their callers. Fix this by defining the responsibility to set an error message to be entirely that of the lower-level function when using SSL. Back-patch to 8.3; the code is too different in 8.2 to be worth the trouble.
* Use OpenSSL's SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.Tom Lane2011-07-24
| | | | | | | | | | | | | | | This disables an entirely unnecessary "sanity check" that causes failures in nonblocking mode, because OpenSSL complains if we move or compact the write buffer. The only actual requirement is that we not modify pending data once we've attempted to send it, which we don't. Per testing and research by Martin Pihlak, though this fix is a lot simpler than his patch. I put the same change into the backend, although it's less clear whether it's necessary there. We do use nonblock mode in some situations in streaming replication, so seems best to keep the same behavior in the backend as in libpq. Back-patch to all supported releases.
* pgindent run before PG 9.1 beta 1.Bruce Momjian2011-04-10
|
* In initialize_SSL, don't fail unnecessarily when home dir is unavailable.Tom Lane2011-03-04
| | | | | | | | | | Instead, just act as though the certificate file(s) are not present. There is only one case where this need be a hard failure condition: when sslmode is verify-ca or verify-full, not having a root cert file is an error. Change the logic so that we complain only in that case, and otherwise fall through cleanly. This is how it used to behave pre-9.0, but my patch 4ed4b6c54e5fab24ab2624d80e26f7546edc88ad of 2010-05-26 broke the case. Per report from Christian Kastner.
* Stamp copyrights for year 2011.Bruce Momjian2011-01-01
|
* Remove cvs keywords from all files.Magnus Hagander2010-09-20
|
* Allow full SSL certificate verification (wherein libpq checks its host nameTom Lane2010-07-14
| | | | | | | | | | | | | | | parameter against server cert's CN field) to succeed in the case where both host and hostaddr are specified. As with the existing precedents for Kerberos, GSSAPI, SSPI, it is the calling application's responsibility that host and hostaddr match up --- we just use the host name as given. Per bug #5559 from Christopher Head. In passing, make the error handling and messages for the no-host-name-given failure more consistent among these four cases, and correct a lie in the documentation: we don't attempt to reverse-lookup host from hostaddr if host is missing. Back-patch to 8.4 where SSL cert verification was introduced.
* pgindent run for 9.0, second runBruce Momjian2010-07-06
|
* Rearrange libpq's SSL initialization to simplify it and make it handle someTom Lane2010-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | additional cases correctly. The original coding failed to load additional (chain) certificates from the client cert file, meaning that indirectly signed client certificates didn't work unless one hacked the server's root.crt file to include intermediate CAs (not the desired approach). Another problem was that everything got loaded into the shared SSL_context object, which meant that concurrent connections trying to use different sslcert settings could well fail due to conflicting over the single available slot for a keyed certificate. To fix, get rid of the use of SSL_CTX_set_client_cert_cb(), which is deprecated anyway in the OpenSSL documentation, and instead just unconditionally load the client cert and private key during connection initialization. This lets us use SSL_CTX_use_certificate_chain_file(), which does the right thing with additional certs, and is lots simpler than the previous hacking about with BIO-level access. A small disadvantage is that we have to load the primary client cert a second time with SSL_use_certificate_file, so that that one ends up in the correct slot within the connection's SSL object where it can get paired with the key. Given the other overhead of making an SSL connection, that doesn't seem worth worrying about. Per discussion ensuing from bug #5468.
* Add missing newlines to some SSL-related error messages. Noted while testing.Tom Lane2010-05-25
|
* pgindent run for 9.0Bruce Momjian2010-02-26
|
* Update copyright for the year 2010.Bruce Momjian2010-01-02
|
* Set errno to zero before invoking SSL_read or SSL_write. It appears thatTom Lane2009-12-30
| | | | | | | | | | | at least in some Windows versions, these functions are capable of returning a failure indication without setting errno. That puts us into an infinite loop if the previous value happened to be EINTR. Per report from Brendan Hill. Back-patch to 8.2. We could take it further back, but since this is only known to be an issue on Windows and we don't support Windows before 8.2, it does not seem worth the trouble.
* Reject certificates with embedded NULLs in the commonName field. This stopsMagnus Hagander2009-12-09
| | | | | | | | | | | | | | | | | | attacks where an attacker would put <attack>\0<propername> in the field and trick the validation code that the certificate was for <attack>. This is a very low risk attack since it reuqires the attacker to trick the CA into issuing a certificate with an incorrect field, and the common PostgreSQL deployments are with private CAs, and not external ones. Also, default mode in 8.4 does not do any name validation, and is thus also not vulnerable - but the higher security modes are. Backpatch all the way. Even though versions 8.3.x and before didn't have certificate name validation support, they still exposed this field for the user to perform the validation in the application code, and there is no way to detect this problem through that API. Security: CVE-2009-4034
* Avoid extra system calls to block SIGPIPE if the platform provides eitherTom Lane2009-07-24
| | | | | | | | | | | | | sockopt(SO_NOSIGPIPE) or the MSG_NOSIGNAL flag to send(). We assume these features are available if (1) the symbol is defined at compile time and (2) the kernel doesn't reject the call at runtime. It might turn out that there are some platforms where (1) and (2) are true and yet the signal isn't really blocked, in which case applications would die on server crash. If that sort of thing gets reported, then we'll have to add additional defenses of some kind. Jeremy Kerr
* Properly initialize SSL engines when used from libpq. This is required forMagnus Hagander2009-06-23
| | | | | | most external engines. Per report and initial code from Lars Kanis
* 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian2009-06-11
| | | | provided by Andrew.
* Fix already-obsolete hint message ... sslverify parameter is no more.Tom Lane2009-05-03
|
* Remove sslverify parameter again, replacing it with two new sslmode values:Magnus Hagander2009-04-24
| | | | | | | "verify-ca" and "verify-full". Since "prefer" remains the default, this will make certificate validation off by default, which should lead to less upgrade issues.
* Add libpq error message text on how to handle missing root.crt file.Bruce Momjian2009-04-14
|
* Add PQinitOpenSSL() function to support applications that use libcryptoTom Lane2009-03-31
| | | | | | but not OpenSSL (or perhaps vice versa, if that's possible). Andrew Chernow, with minor editorialization by me.
* Clarify variable naming: pq_initssllib -> pq_init_ssl_libBruce Momjian2009-03-28
|
* Better document PQinitSSL(0) behavior in regards to libcrypto.Bruce Momjian2009-03-28
|
* Go over all OpenSSL return values and make sure we compare themMagnus Hagander2009-01-28
| | | | | | | | to the documented API value. The previous code got it right as it's implemented, but accepted too much/too little compared to the API documentation. Per comment from Zdenek Kotala.
* Fix accidental (I suppose) introduction of non-ASCII quote marks.Tom Lane2009-01-19
|
* Message wordsmithingPeter Eisentraut2009-01-19
|
* Don't require pqGetHomeDirectory to succeed if the user has specifiedMagnus Hagander2009-01-07
| | | | | | hardcoded paths for SSL rootcert/crl/clientcert/key. As noted by Andrew Chernow
* Update copyright for 2009.Bruce Momjian2009-01-01
|
* Support specifying filename for SSL certificate, key, root certificate storeMagnus Hagander2008-12-15
| | | | | | | | and certificate revokation list by using connection parameters or environment variables. Original patch by Mark Woodward, heavily reworked by Alvaro Herrera and Magnus Hagander.
* Comment said we don't free the lockarray, and why. The proper fix is toMagnus Hagander2008-12-04
| | | | make the code do what the comment says...
* Fix typo in recent SSL unload patch.Bruce Momjian2008-12-04
| | | | Kris Jurka
* Properly unregister OpenSSL callbacks when libpq is done withMagnus Hagander2008-12-03
| | | | | | | | | | | | | | it's connection. This is required for applications that unload the libpq library (such as PHP) in which case we'd otherwise have pointers to these functions when they no longer exist. This needs a bit more testing before we can consider a backpatch, so not doing that yet. In passing, remove unused functions in backend/libpq. Bruce Momjian and Magnus Hagander, per report and analysis by Russell Smith.
* Change wildcard cerfificate mapping to be much simler - we now only matchMagnus Hagander2008-12-02
| | | | | | | | the * character at the beginning of a pattern, and it does not match subdomains. Since this means we no longer need fnmatch, remove the imported implementation from port, along with the autoconf check for it.
* Disable FNM_CASEFOLD. Need a proper solution later, but just commentMagnus Hagander2008-11-24
| | | | it out for now so the buildfarm recovers.
* Add support for matching wildcard server certificates to the new SSL code.Magnus Hagander2008-11-24
| | | | | This uses the function fnmatch() which is not available on all platforms (notably Windows), so import the implementation from NetBSD into src/port.
* Fix libpq certificate validation for SSL connections.Magnus Hagander2008-11-13
| | | | | | | Add config parameter "sslverify" to control the verification. Default is to do full verification. Clean up some old SSL code that never really worked.
* Remove notes from the frontend SSL source that are incorrect orMagnus Hagander2008-10-24
| | | | end-user documentation that lives in the actual documentation.
* Implement error checking for pthreads calls in thread-safe mode. They reallyMagnus Hagander2008-05-16
| | | | | | | | | should always succeed, but in the likely event of a failure we would previously fall through *without locking* - the new code will exit(1). Printing the error message on stderr will not work for all applications, but it's better than nothing at all - and our API doesn't provide a way to return the error to the caller.
* Use error message wordings for permissions checks on .pgpass and SSL privateTom Lane2008-03-31
| | | | | | | | | | | | key files that are similar to the one for the postmaster's data directory permissions check. (I chose to standardize on that one since it's the most heavily used and presumably best-wordsmithed by now.) Also eliminate explicit tests on file ownership in these places, since the ensuing read attempt must fail anyway if it's wrong, and there seems no value in issuing the same error message for distinct problems. (But I left in the explicit ownership test in postmaster.c, since it had its own error message anyway.) Also be more specific in the documentation's descriptions of these checks. Per a gripe from Kevin Hunter.
* Rename a libpq NOT_USED SSL function toBruce Momjian2008-02-16
| | | | | | verify_peer_name_matches_certificate(), clarify some of the function's variables and logic, and update a comment. This should make SSL improvements easier in the future.
* Arrange to ignore SIGPIPE during SSL_read() and SSL_shutdown(), as theseTom Lane2008-01-29
| | | | | | | | | are known to write on the socket sometimes and thus we are vulnerable to being killed by the signal if the server happens to go away unexpectedly. Noticed while trying (futilely) to reproduce bug #3902. This bug has been there all along, but since the situation is usually only of interest to developers, I chose not to back-patch the changes.
* Update copyrights in source tree to 2008.Bruce Momjian2008-01-01
|
* pgindent run for 8.3.Bruce Momjian2007-11-15
|