From dba5e098767b71bb017fa191cc3f07dc68437655 Mon Sep 17 00:00:00 2001 From: runge Date: Sun, 17 Sep 2006 18:08:23 +0000 Subject: x11vnc: -verbose, -connect_or_exit, -rfbport 0, print out SSL cert. --- x11vnc/sslcmds.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'x11vnc/sslcmds.c') diff --git a/x11vnc/sslcmds.c b/x11vnc/sslcmds.c index cf69910..d1ed95c 100644 --- a/x11vnc/sslcmds.c +++ b/x11vnc/sslcmds.c @@ -314,6 +314,7 @@ void setup_stunnel(int rport, int *argc, char **argv) { argv[i+1] = strdup(tmp); *argc += 2; got_rfbport = 1; + got_rfbport_val = atoi(tmp); } } stunnel_port = rport; @@ -710,14 +711,34 @@ void sslEncKey(char *path, int mode) { unlink(tmp); if (! mode && cert && cert[0] != '\0') { - file = fopen(path, "a"); + int got_cert = 0; + file = fopen(path, "r"); if (file == NULL) { rfbLog("sslEncKey: %s\n", path); rfbLogPerror("fopen"); exit(1); } - fprintf(file, "%s", cert); + while (fgets(line, 1024, file) != NULL) { + if (strstr(line, "-----BEGIN CERTIFICATE-----") + == line) { + got_cert++; + } + if (strstr(line, "-----END CERTIFICATE-----") + == line) { + got_cert++; + } + } fclose(file); + if (got_cert < 2) { + file = fopen(path, "a"); + if (file == NULL) { + rfbLog("sslEncKey: %s\n", path); + rfbLogPerror("fopen"); + exit(1); + } + fprintf(file, "%s", cert); + fclose(file); + } free(cert); } -- cgit v1.2.3