1 /* $OpenBSD: tls_peer.c,v 1.4 2015/09/12 21:00:38 beck Exp $ */
3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <openssl/x509.h>
24 #include "tls_internal.h"
27 tls_peer_cert_hash(struct tls *ctx)
30 return (ctx->conninfo->hash);
34 tls_peer_cert_issuer(struct tls *ctx)
37 return (ctx->conninfo->issuer);
42 tls_peer_cert_subject(struct tls *ctx)
45 return (ctx->conninfo->subject);
50 tls_peer_cert_provided(struct tls *ctx)
52 return (ctx->ssl_peer_cert != NULL);
56 tls_peer_cert_contains_name(struct tls *ctx, const char *name)
58 if (ctx->ssl_peer_cert == NULL)
61 return (tls_check_name(ctx, ctx->ssl_peer_cert, name) == 0);
65 tls_peer_cert_notbefore(struct tls *ctx)
67 if (ctx->ssl_peer_cert == NULL)
69 if (ctx->conninfo == NULL)
71 return (ctx->conninfo->notbefore);
75 tls_peer_cert_notafter(struct tls *ctx)
77 if (ctx->ssl_peer_cert == NULL)
79 if (ctx->conninfo == NULL)
81 return (ctx->conninfo->notafter);