-EXTRA_DIST = extra.h openssl.h gnutls.h compat4.h x509.h compat8.h pkcs12.h
+EXTRA_DIST = extra.h openssl.h gnutls.h compat4.h x509.h compat8.h pkcs12.h openpgp.h
{
uint8 data[2];
int ret;
-
+ const char *name;
+
data[0] = (uint8) level;
data[1] = (uint8) desc;
- _gnutls_record_log( "REC: Sending Alert[%d|%d] - %s\n", data[0], data[1], gnutls_alert_get_name((int)data[1]));
+ name = gnutls_alert_get_name((int)data[1]);
+ if (name == NULL) name = "(unknown)";
+ _gnutls_record_log( "REC: Sending Alert[%d|%d] - %s\n", data[0], data[1], name);
if ( (ret = _gnutls_send_int( session, GNUTLS_ALERT, -1, data, 2)) >= 0)
return 0;
* gnutls_mac_get_name - Returns a string with the name of the specified mac algorithm
* @algorithm: is a MAC algorithm
*
- * Returns a string that contains the name
- * of the specified MAC algorithm.
+ * Returns a string that contains the name
+ * of the specified MAC algorithm or NULL.
**/
const char *gnutls_mac_get_name( gnutls_mac_algorithm algorithm)
{
* gnutls_compression_get_name - Returns a string with the name of the specified compression algorithm
* @algorithm: is a Compression algorithm
*
- * Returns a pointer to a string that contains the name
- * of the specified compression algorithm.
+ * Returns a pointer to a string that contains the name
+ * of the specified compression algorithm or NULL.
**/
const char *gnutls_compression_get_name( gnutls_compression_method algorithm)
{
* gnutls_cipher_get_name - Returns a string with the name of the specified cipher algorithm
* @algorithm: is an encryption algorithm
*
- * Returns a pointer to a string that contains the name
- * of the specified cipher.
+ * Returns a pointer to a string that contains the name
+ * of the specified cipher or NULL.
**/
const char *gnutls_cipher_get_name( gnutls_cipher_algorithm algorithm)
{
* @algorithm: is a key exchange algorithm
*
* Returns a pointer to a string that contains the name
- * of the specified key exchange algorithm.
+ * of the specified key exchange algorithm or NULL.
**/
const char *gnutls_kx_get_name( gnutls_kx_algorithm algorithm)
{
* gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version
* @version: is a (gnutls) version number
*
- * Returns a string that contains the name
- * of the specified TLS version.
+ * Returns a string that contains the name
+ * of the specified TLS version or NULL.
**/
const char *gnutls_protocol_get_name( gnutls_protocol_version version)
{
* @mac_algorithm: is a MAC algorithm
*
* Returns a string that contains the name of a TLS
- * cipher suite, specified by the given algorithms.
+ * cipher suite, specified by the given algorithms, or NULL.
*
* Note that the full cipher suite name must be prepended
* by TLS or SSL depending of the protocol in use.
INCLUDES = -I../ -I../minitasn1/ -I../../includes/
EXTRA_DIST = dn.h common.h x509.h extensions.h pkcs7.h \
x509-api.tex compat.h verify.h mpi.h crq.h sign.h pkcs5.h \
- privkey.h pkcs12.h rc2.h
+ privkey.h pkcs12.h rc2.h rfc2818.h
noinst_LTLIBRARIES = libx509.la
#lib_LTLIBRARIES = libgnutls-x509.la
#include <dn.h>
#include <common.h>
#include <gnutls/compat8.h>
-
-static int hostname_compare(const char *certname, const char *hostname);
+#include <rfc2818.h>
/*-
* gnutls_x509_check_certificates_hostname - This function compares the given hostname with the hostname in the certificate
int gnutls_x509_check_certificates_hostname(const gnutls_datum * cert,
const char *hostname)
{
-#define MAX_CN 256
char dnsname[MAX_CN];
int dnsnamesize;
int found_dnsname = 0;
if (ret == GNUTLS_SAN_DNSNAME) {
found_dnsname = 1;
- if (hostname_compare(dnsname, hostname)) {
+ if (_gnutls_hostname_compare(dnsname, hostname)) {
return 1;
}
}
return 0;
}
- if (hostname_compare(dn.common_name, hostname)) {
+ if (_gnutls_hostname_compare(dn.common_name, hostname)) {
return 1;
}
}
/* compare hostname against certificate, taking account of wildcards
* return 1 on success or 0 on error
*/
-static int hostname_compare(const char *certname, const char *hostname)
+int _gnutls_hostname_compare(const char *certname, const char *hostname)
{
const char *cmpstr1, *cmpstr2;
if (ret == GNUTLS_SAN_DNSNAME) {
found_dnsname = 1;
- if (hostname_compare(dnsname, hostname)) {
+ if (_gnutls_hostname_compare(dnsname, hostname)) {
return 1;
}
}
return 0;
}
- if (hostname_compare(dnsname, hostname)) {
+ if (_gnutls_hostname_compare(dnsname, hostname)) {
return 1;
}
}
libgnutls_extra_la_LDFLAGS = $(libgnutls_extra_version_script_cmd) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
$(LIBOPENCDK_LIBS) $(LZO_LINK)
-libgnutls_extra_la_LIBADD = $(LZO_OBJECTS) ../lib/libgnutls.la
libgnutls_extra_la_DEPENDENCIES = $(LZO_OBJECTS)
libgnutls_extra_la_SOURCES = $(COBJECTS_EXTRA)
-libgnutls_extra_la_LIBADD = openpgp/openpgp.lo openpgp/xml.lo openpgp/gnutls_openpgp.lo
+libgnutls_extra_la_LIBADD = $(LZO_OBJECTS) ../lib/libgnutls.la \
+ openpgp/openpgp.lo openpgp/xml.lo openpgp/gnutls_openpgp.lo
EXTRA_libgnutls_extra_la_SOURCES = minilzo.c
#include <sys/time.h>
#include <signal.h>
#include <netdb.h>
-#include <common.h>
+#include "common.h"
#include "cli-gaa.h"
#ifndef SHUT_WR
}
str = gnutls_strerror(err);
- if (str == NULL) str = "(unknown)";
+ if (str == NULL) str = str_unknown;
fprintf(stderr,
"*** %s error: %s\n", err_type, str);
|| err == GNUTLS_E_FATAL_ALERT_RECEIVED) {
alert = gnutls_alert_get(hd.session);
str = gnutls_alert_get_name(alert);
- if (str == NULL) str = "(unknown)";
+ if (str == NULL) str = str_unknown;
printf("*** Received alert [%d]: %s\n", alert, str);
}
return ret;
}
-int starttls_alarmed;
+int starttls_alarmed = 0;
void starttls_alarm (int signum)
{
#define PRINT_PGP_NAME(X) PRINTX( "NAME:", X.name); \
PRINTX( "EMAIL:", X.email)
+const char str_unknown[] = "(unknown)";
+
static const char *my_ctime(const time_t * tv)
{
static char buf[256];
if ( ( (tp = localtime(tv)) == NULL ) ||
(!strftime(buf, sizeof buf, "%a %b %e %H:%M:%S %Z %Y\n", tp)) )
- strcpy(buf, "unknown"); /* make sure buf text isn't garbage */
+ strcpy(buf, str_unknown);/* make sure buf text isn't garbage */
return buf;
GNUTLS_X509_FMT_DER);
if (ret < 0) {
const char* str = gnutls_strerror(ret);
- if (str == NULL) str = "(unknown)";
+ if (str == NULL) str = str_unknown;
fprintf(stderr, "Decoding error: %s\n", str);
return;
}
ret = gnutls_x509_crt_to_xml( crt, &xml_data, 0);
if (ret < 0) {
const char* str = gnutls_strerror(ret);
- if (str == NULL) str = "(unknown)";
+ if (str == NULL) str = str_unknown;
fprintf(stderr, "XML encoding error: %s\n",
str);
return;
if ((ret=gnutls_x509_crt_get_fingerprint(crt, GNUTLS_DIG_MD5, digest, &digest_size))
< 0) {
const char* str = gnutls_strerror(ret);
- if (str == NULL) str = "(unknown)";
+ if (str == NULL) str = str_unknown;
fprintf(stderr, "Error in fingerprint calculation: %s\n", str);
} else {
print = printable;
tmp =
gnutls_protocol_get_name(gnutls_protocol_get_version(session));
- printf("- Version: %s\n", tmp);
+ if (tmp != NULL) printf("- Version: %s\n", tmp);
tmp = gnutls_kx_get_name(kx);
- printf("- Key Exchange: %s\n", tmp);
+ if (tmp != NULL) printf("- Key Exchange: %s\n", tmp);
tmp = gnutls_cipher_get_name(gnutls_cipher_get(session));
- printf("- Cipher: %s\n", tmp);
+ if (tmp != NULL) printf("- Cipher: %s\n", tmp);
tmp = gnutls_mac_get_name(gnutls_mac_get(session));
- printf("- MAC: %s\n", tmp);
+ if (tmp != NULL) printf("- MAC: %s\n", tmp);
tmp = gnutls_compression_get_name(gnutls_compression_get(session));
- printf("- Compression: %s\n", tmp);
+ if (tmp != NULL) printf("- Compression: %s\n", tmp);
fflush (stdout);
*/
#define PRI_MAX 16
+extern const char str_unknown[];
+
int print_info( gnutls_session state, const char* hostname);
void print_cert_info( gnutls_session state, const char* hostname);
void print_list(void);
#define SA struct sockaddr
#define ERR(err,s) if(err==-1) {perror(s);return(1);}
-#define GERR(ret) fprintf(stdout, "Error: %s\n", gnutls_strerror(ret))
+#define GERR(ret) fprintf(stdout, "Error: %s\n", safe_strerror(ret))
#define MAX_BUF 1024
#undef max
int http_state;
int fd; gnutls_session tls_session; int handshake_ok;);
+static const char *safe_strerror(int value)
+{ const char *ret = gnutls_strerror(value);
+ if (ret == NULL) ret = str_unknown;
+ return ret;
+}
+
static void listener_free(listener_item * j)
{
if (j->http_request)
size = gnutls_dh_params_import_pkcs3( dh_params, ¶ms, GNUTLS_X509_FMT_PEM);
if (size < 0) {
- fprintf(stderr, "Error parsing dh params: %s\n", gnutls_strerror(size));
+ fprintf(stderr, "Error parsing dh params: %s\n", safe_strerror(size));
exit(1);
}
strcat(http_buffer, "<P>\n");
tmp = gnutls_protocol_get_name(gnutls_protocol_get_version(session));
+ if (tmp == NULL) tmp = str_unknown;
sprintf(tmp2,
"<TABLE border=1><TR><TD>Protocol version:</TD><TD>%s</TD></TR>\n",
tmp);
tmp =
gnutls_certificate_type_get_name(gnutls_certificate_type_get
(session));
+ if (tmp == NULL) tmp = str_unknown;
sprintf(tmp2, "<TR><TD>Certificate Type:</TD><TD>%s</TD></TR>\n",
tmp);
}
tmp = gnutls_kx_get_name(kx_alg);
+ if (tmp == NULL) tmp = str_unknown;
sprintf(tmp2, "<TR><TD>Key Exchange:</TD><TD>%s</TD></TR>\n", tmp);
tmp = gnutls_compression_get_name(gnutls_compression_get(session));
+ if (tmp == NULL) tmp = str_unknown;
sprintf(tmp2, "<TR><TD>Compression</TD><TD>%s</TD></TR>\n", tmp);
tmp = gnutls_cipher_get_name(gnutls_cipher_get(session));
+ if (tmp == NULL) tmp = str_unknown;
sprintf(tmp2, "<TR><TD>Cipher</TD><TD>%s</TD></TR>\n", tmp);
tmp = gnutls_mac_get_name(gnutls_mac_get(session));
+ if (tmp == NULL) tmp = str_unknown;
sprintf(tmp2, "<TR><TD>MAC</TD><TD>%s</TD></TR>\n", tmp);
tmp = gnutls_cipher_suite_get_name(kx_alg,
gnutls_cipher_get(session),
gnutls_mac_get(session));
+ if (tmp == NULL) tmp = str_unknown;
sprintf(tmp2, "<TR><TD>Ciphersuite</TD><TD>%s</TD></TR></p></TABLE>\n",
tmp);
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGTERM, terminate);
- signal(SIGINT, terminate);
- /* CHECKME: background processes shouldn't handle SIGINT! */
+ if (signal(SIGINT, terminate) == SIG_IGN)
+ signal(SIGINT, SIG_IGN); /* e.g. background process */
gaa_parser(argc, argv);
unsigned int keyfpr_length, gnutls_datum * key)
{
static const char hostname[] = "hkp://wwwkeys.pgp.net";
- static const short port = 11371;
+ static const int port = 11371;
int rc;
CDK_KBNODE knode = NULL;
unsigned int i;