summaryrefslogtreecommitdiffstats
path: root/common/ssl_verify.c
Commit message (Collapse)AuthorAgeFilesLines
* ssl-verify: Don't leak GInetAddressChristophe Fergeau2015-11-271-2/+8
| | | | | GInetAddress is a GObject, so we must unref anything we create with g_inet_address_new_*
* ssl-verify: Handle NULL return from g_inet_address_new_from_string()Christophe Fergeau2015-11-271-2/+6
| | | | It will return NULL if the string we pass it cannot be parsed.
* ssl-verify: Changed IPv4 hostname to IPv6Lukas Venhoda2015-10-231-24/+21
| | | | | | | | Change inet_aton function to glib functions. inet_aton only supported IPv4 addresses, and wasn't available on windows machines. GInetAddress functions support IPv6 natively, and requires less boilerplate code then IPv6 gettaddrinfo().
* ssl-verify: Only check addr length when using IP addrLukas Venhoda2015-10-231-7/+8
| | | | | Only check for address length, when connecting through IP address. It is not used, when connecting through DNS hostname.
* ssl: Don't use uninitialized variable in verify_subject()Christophe Fergeau2014-01-071-11/+9
| | | | | | | | | | | | If verify_subject() is called with a SpiceOpenSSLVerify struct containing a non-NULL 'in_subject' member, it would try to use the local 'in_entries' variable without having initialized it first. This could happen if verify_subject() was called multiple time with the same SpiceOpenSSLVerify context, which probably isn't occurring the way we are using it. However, since verify_subject() is the only method which needs in_subject, we don't need to have it stored in SpiceOpenSSLVerify, and we can recreate it as needed locally in that method, which avoids that issue.
* ssl: Don't try hostname check if cert subject check failsChristophe Fergeau2013-10-111-8/+5
| | | | | | | | | | | | | | | | | | Currently, SSL verification of the peer certificate checks if the certificate's subject CN or one of its subjectAltName match the hostname. If this succeeds, then the verification succeeds. Otherwise openssl_verify() checks the cert subject if this was set, which means it checks the certificate's subject (not just its CN) matches exactly the cert subject string that is set in SpiceSession. Given that the cert subject is something the user specifies in addition to the hostname, the cert subject check should have priority over the hostname check, that is, when we have a cert subject set, the success/failure of the cert subject cert should determine the success/failure of openssl_verify(), and the hostname check should only be carried out when no cert subject was set. This fixes rhbz#871034
* ssl: Log an error when peer certificate verification failedChristophe Fergeau2013-10-111-1/+9
| | | | | | | We currently log an error when openssl_verify() is called with preverify_ok set to 0 for all certificates in the certificate chain except for the peer certificate (when 'depth' is 0). This commit logs an error in the latter case as well.
* ssl: Improve error message in cert chain verificationChristophe Fergeau2013-10-111-2/+2
| | | | It contains the same information as before, but should be more readable.
* ssl-verify: use more explicit error messageMarc-André Lureau2012-10-181-0/+3
| | | | | | | | | | | | | When the server certificate is not being signed by the provided CA, the SSL debug message is currently for example: ssl_verify.c:428:openssl_verify: openssl verify:num=19:self signed certificate in certificate chain:depth=1:/C=IL/L=Raanana/O=Red Hat/CN=my CA Add a more explicit debug message too, as requested in bug: https://bugzilla.redhat.com/show_bug.cgi?id=846666
* Fix a gcc warningMarc-André Lureau2012-06-301-3/+6
| | | | warning: suggest explicit braces to avoid ambiguous 'else'
* ssl: more verbose output when SSL verification failsChristophe Fergeau2012-06-251-9/+32
| | | | This should make SSL connection failures easier to diagnose.
* ssl-verify: add a bit of run-time checksMarc-André Lureau2012-05-171-0/+5
| | | | | Even if they are not public functions, those conditions can be reached in a invalid state.
* move variable decleration to head of code blockAric Stewart2012-04-181-1/+1
| | | | Signed-off-by: Aric Stewart <aric@codeweavers.com>
* Bypass certicate verification failure if PUBKEY check onlyMarc-André Lureau2012-03-301-0/+7
| | | | | | | During switch-host migration, only PUBKEY verification is required. Couldn't it just load the certificate again for the new session? perhaps, but that's they way the code used to work until I introduced a regression in spice commit d46f9d3f4e006d3bca9b99fac25169b17e7ac803.
* ssl-verify: improve logging report in case of errorsMarc-André Lureau2012-03-301-30/+40
| | | | Use the log.h system, and report a bit more information in the debug level
* Add missing includes & make some functions staticDaniel P. Berrange2012-03-201-2/+2
| | | | | | | | | A number of functions were used without prior declaration. In some cases this was due to missing include files. In other cases the functions should have just been static. Ideally this would allow -Wmissing-declarations to be enabled, but the files generated by spice_codegen.py will still trip up on this.
* Avoid warnings about empty conditional statement bodiesDaniel P. Berrange2012-03-201-6/+9
| | | | | | | | | | | | Add extra {} braces around if/else statements which only call SPICE_DEBUG to avoid: ../common/ssl_verify.c: In function 'verify_pubkey': ../common/ssl_verify.c:87:50: warning: suggest braces around empty body in an 'else' statement [-Wempty-body] ../common/ssl_verify.c: In function 'verify_hostname': ../common/ssl_verify.c:254:53: warning: suggest braces around empty body in an 'if' statement [-Wempty-body] ../common/ssl_verify.c: In function 'verify_subject': ../common/ssl_verify.c:381:41: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
* ssl_verify: include <string.h>Christophe Fergeau2012-03-201-0/+1
| | | | | ssl_verify.c is using memcmp which comes from string.h, this was breaking compilation with -Werror -Wall on Mac OS X
* common: fix ssl_verify windows build errorsArnon Gilboa2012-03-201-2/+3
|
* common: add ssl_verify.c common codeMarc-André Lureau2012-03-201-0/+481
Code adapter from RedPeer::ssl_verify_callback() and used by spice-gtk. Since v1: - fixed Makefile.am - added config.h include - autoconf alloca added in patch series - moved int escape inside for loop - added a failed case when missing assignment - replaced strlen () by -1 - skip spaces after comma - c++ guards I didn't use bool, because openSSL uses int, and it is more future proof for error reporting.