From c6cd90c2dd491d31d7bf8cff3e31bf361a955b1b Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Sun, 10 Jan 2021 18:00:41 -0500 Subject: Print chain to stdout with -o --- irc.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'irc.c') diff --git a/irc.c b/irc.c index cbe1808..c98193a 100644 --- a/irc.c +++ b/irc.c @@ -160,20 +160,11 @@ int ircConnect(const char *bindHost, const char *host, const char *port) { return sock; } -void ircWriteChain(const char *path) { - FILE *file = fopen(path, "w"); - if (!file) err(EX_CANTCREAT, "%s", path); - - int n = fprintf(file, "subject= %s\n", tls_peer_cert_subject(client)); - if (n < 0) err(EX_IOERR, "%s", path); - +void ircPrintCert(void) { size_t len; const byte *pem = tls_peer_cert_chain_pem(client, &len); - len = fwrite(pem, len, 1, file); - if (!len) err(EX_IOERR, "%s", path); - - int error = fclose(file); - if (error) err(EX_IOERR, "%s", path); + printf("subject= %s\n", tls_peer_cert_subject(client)); + fwrite(pem, len, 1, stdout); } enum { MessageCap = 8191 + 512 }; -- cgit 1.4.1-2-gfad0