00001 /* Obtained from: https://github.com/iSECPartners/ssl-conservatory */ 00002 00003 /* 00004 Copyright (C) 2012, iSEC Partners. 00005 00006 Permission is hereby granted, free of charge, to any person obtaining a copy of 00007 this software and associated documentation files (the "Software"), to deal in 00008 the Software without restriction, including without limitation the rights to 00009 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 00010 of the Software, and to permit persons to whom the Software is furnished to do 00011 so, subject to the following conditions: 00012 00013 The above copyright notice and this permission notice shall be included in all 00014 copies or substantial portions of the Software. 00015 00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00021 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00022 SOFTWARE. 00023 */ 00024 00025 /* 00026 * Helper functions to perform basic hostname validation using OpenSSL. 00027 * 00028 * Please read "everything-you-wanted-to-know-about-openssl.pdf" before 00029 * attempting to use this code. This whitepaper describes how the code works, 00030 * how it should be used, and what its limitations are. 00031 * 00032 * Author: Alban Diquet 00033 * License: See LICENSE 00034 * 00035 */ 00036 00037 typedef enum { 00038 MatchFound, 00039 MatchNotFound, 00040 NoSANPresent, 00041 MalformedCertificate, 00042 Error 00043 } HostnameValidationResult; 00044 00056 HostnameValidationResult validate_hostname(const char *hostname, const X509 *server_cert);