Blame SOURCES/openssl-1.0.2j-krb5keytab.patch

aa8173
diff -up openssl-1.0.2j/apps/s_client.c.krb5keytab openssl-1.0.2j/apps/s_client.c
aa8173
--- openssl-1.0.2j/apps/s_client.c.krb5keytab	2017-01-05 17:02:05.481441088 +0100
aa8173
+++ openssl-1.0.2j/apps/s_client.c	2017-01-05 17:08:28.311073180 +0100
aa8173
@@ -171,6 +171,10 @@ typedef unsigned int u_int;
aa8173
 #include "s_apps.h"
aa8173
 #include "timeouts.h"
aa8173
 
aa8173
+#ifndef OPENSSL_NO_KRB5
aa8173
+static char *krb5svc = NULL;
aa8173
+#endif
aa8173
+
aa8173
 #if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
aa8173
 /* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
aa8173
 # undef FIONBIO
aa8173
@@ -400,6 +404,9 @@ static void sc_usage(void)
aa8173
     BIO_printf(bio_err,
aa8173
                "                 only \"smtp\", \"pop3\", \"imap\", \"ftp\" and \"xmpp\"\n");
aa8173
     BIO_printf(bio_err, "                 are supported.\n");
aa8173
+#ifndef OPENSSL_NO_KRB5
aa8173
+    BIO_printf(bio_err, " -krb5svc arg  - Kerberos service name\n");
aa8173
+#endif
aa8173
 #ifndef OPENSSL_NO_ENGINE
aa8173
     BIO_printf(bio_err,
aa8173
                " -engine id    - Initialise and use the specified engine\n");
aa8173
@@ -1069,6 +1076,13 @@ int MAIN(int argc, char **argv)
aa8173
             c_nbio = 1;
aa8173
         }
aa8173
 #endif
aa8173
+#ifndef OPENSSL_NO_KRB5
aa8173
+	else if	(strcmp(*argv, "-krb5svc") == 0) {
aa8173
+            if (--argc < 1)
aa8173
+                goto bad;
aa8173
+            krb5svc= *(++argv);
aa8173
+        }
aa8173
+#endif
aa8173
         else if (strcmp(*argv, "-starttls") == 0) {
aa8173
             if (--argc < 1)
aa8173
                 goto bad;
aa8173
@@ -1435,6 +1449,8 @@ int MAIN(int argc, char **argv)
aa8173
     if (con && (kctx = kssl_ctx_new()) != NULL) {
aa8173
         SSL_set0_kssl_ctx(con, kctx);
aa8173
         kssl_ctx_setstring(kctx, KSSL_SERVER, host);
aa8173
+        if (krb5svc != NULL)
aa8173
+            kssl_ctx_setstring(kctx, KSSL_SERVICE, krb5svc);
aa8173
     }
aa8173
 #endif                          /* OPENSSL_NO_KRB5 */
aa8173
 /*      SSL_set_cipher_list(con,"RC4-MD5"); */
aa8173
diff -up openssl-1.0.2j/apps/s_server.c.krb5keytab openssl-1.0.2j/apps/s_server.c
aa8173
--- openssl-1.0.2j/apps/s_server.c.krb5keytab	2017-01-05 17:02:05.482441111 +0100
aa8173
+++ openssl-1.0.2j/apps/s_server.c	2017-01-05 17:16:36.458078609 +0100
aa8173
@@ -206,6 +206,11 @@ typedef unsigned int u_int;
aa8173
 # include <fcntl.h>
aa8173
 #endif
aa8173
 
aa8173
+#ifndef OPENSSL_NO_KRB5
aa8173
+static char *krb5svc = NULL;
aa8173
+static char *keytab = NULL;
aa8173
+#endif
aa8173
+
aa8173
 #ifndef OPENSSL_NO_RSA
aa8173
 static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength);
aa8173
 #endif
aa8173
@@ -579,6 +584,10 @@ static void sv_usage(void)
aa8173
     BIO_printf(bio_err, " -serverpref   - Use server's cipher preferences\n");
aa8173
     BIO_printf(bio_err, " -quiet        - No server output\n");
aa8173
     BIO_printf(bio_err, " -no_tmp_rsa   - Do not generate a tmp RSA key\n");
aa8173
+#ifndef OPENSSL_NO_KRB5
aa8173
+    BIO_printf(bio_err, " -krb5svc arg  - Kerberos service name\n");
aa8173
+    BIO_printf(bio_err, " -keytab arg   - Kerberos keytab filename\n");
aa8173
+#endif
aa8173
 #ifndef OPENSSL_NO_PSK
aa8173
     BIO_printf(bio_err, " -psk_hint arg - PSK identity hint to use\n");
aa8173
     BIO_printf(bio_err, " -psk arg      - PSK in hex (without 0x)\n");
aa8173
@@ -1326,6 +1335,17 @@ int MAIN(int argc, char *argv[])
aa8173
                 goto bad;
aa8173
             vfyCAfile = *(++argv);
aa8173
         }
aa8173
+#ifndef OPENSSL_NO_KRB5
aa8173
+        else if (strcmp(*argv, "-krb5svc") == 0) {
aa8173
+            if (--argc < 1)
aa8173
+                goto bad;
aa8173
+            krb5svc = *(++argv);
aa8173
+        } else if (strcmp(*argv, "-keytab") == 0) {
aa8173
+            if (--argc < 1)
aa8173
+                goto bad;
aa8173
+            keytab = *(++argv);
aa8173
+        }
aa8173
+#endif
aa8173
 #ifdef FIONBIO
aa8173
         else if (strcmp(*argv, "-nbio") == 0) {
aa8173
             s_nbio = 1;
aa8173
@@ -2226,8 +2246,10 @@ static int sv_body(char *hostname, int s
aa8173
 #ifndef OPENSSL_NO_KRB5
aa8173
         if ((kctx = kssl_ctx_new()) != NULL) {
aa8173
             SSL_set0_kssl_ctx(con, kctx);
aa8173
-            kssl_ctx_setstring(kctx, KSSL_SERVICE, KRB5SVC);
aa8173
-            kssl_ctx_setstring(kctx, KSSL_KEYTAB, KRB5KEYTAB);
aa8173
+            kssl_ctx_setstring(kctx, KSSL_SERVICE,
aa8173
+                krb5svc == NULL ? KRB5SVC : krb5svc);
aa8173
+            if (keytab != NULL)
aa8173
+                kssl_ctx_setstring(kctx, KSSL_KEYTAB, keytab);
aa8173
         }
aa8173
 #endif                          /* OPENSSL_NO_KRB5 */
aa8173
         if (context)
aa8173
@@ -2836,8 +2858,11 @@ static int www_body(char *hostname, int
aa8173
 #endif
aa8173
 #ifndef OPENSSL_NO_KRB5
aa8173
     if ((kctx = kssl_ctx_new()) != NULL) {
aa8173
-        kssl_ctx_setstring(kctx, KSSL_SERVICE, KRB5SVC);
aa8173
-        kssl_ctx_setstring(kctx, KSSL_KEYTAB, KRB5KEYTAB);
aa8173
+        SSL_set0_kssl_ctx(con, kctx);
aa8173
+        kssl_ctx_setstring(kctx, KSSL_SERVICE,
aa8173
+            krb5svc == NULL ? KRB5SVC : krb5svc);
aa8173
+        if (keytab != NULL)
aa8173
+            kssl_ctx_setstring(kctx, KSSL_KEYTAB, keytab);
aa8173
     }
aa8173
 #endif                          /* OPENSSL_NO_KRB5 */
aa8173
     if (context)
aa8173
diff -up openssl-1.0.2j/doc/apps/s_client.pod.krb5keytab openssl-1.0.2j/doc/apps/s_client.pod
aa8173
--- openssl-1.0.2j/doc/apps/s_client.pod.krb5keytab	2016-09-26 11:49:07.000000000 +0200
aa8173
+++ openssl-1.0.2j/doc/apps/s_client.pod	2017-01-05 17:21:30.562709291 +0100
aa8173
@@ -43,6 +43,7 @@ B<openssl> B<s_client>
aa8173
 [B<-fallback_scsv>]
aa8173
 [B<-bugs>]
aa8173
 [B<-cipher cipherlist>]
aa8173
+[B<-krb5svc service>]
aa8173
 [B<-serverpref>]
aa8173
 [B<-starttls protocol>]
aa8173
 [B<-engine id>]
aa8173
@@ -228,6 +229,12 @@ command for more information.
aa8173
 
aa8173
 use the server's cipher preferences; only used for SSLV2.
aa8173
 
aa8173
+=item B<-krb5svc service>
aa8173
+
aa8173
+the Kerberos service name to use (default "host"). This means s_server
aa8173
+will expect a ticket for the principal I<service>/hostname@REALM, and will
aa8173
+need keys for that principal in its keytab.
aa8173
+
aa8173
 =item B<-starttls protocol>
aa8173
 
aa8173
 send the protocol-specific message(s) to switch to TLS for communication.
aa8173
diff -up openssl-1.0.2j/doc/apps/s_server.pod.krb5keytab openssl-1.0.2j/doc/apps/s_server.pod
aa8173
--- openssl-1.0.2j/doc/apps/s_server.pod.krb5keytab	2017-01-05 17:02:05.482441111 +0100
aa8173
+++ openssl-1.0.2j/doc/apps/s_server.pod	2017-01-05 17:20:54.769902331 +0100
aa8173
@@ -37,6 +37,8 @@ B<openssl> B<s_server>
aa8173
 [B<-nocert>]
aa8173
 [B<-cipher cipherlist>]
aa8173
 [B<-serverpref>]
aa8173
+[B<-krb5svc service>]
aa8173
+[B<-keytab filename>]
aa8173
 [B<-quiet>]
aa8173
 [B<-no_tmp_rsa>]
aa8173
 [B<-ssl2>]
aa8173
@@ -246,6 +248,17 @@ the B<ciphers> command for more informat
aa8173
 
aa8173
 use the server's cipher preferences, rather than the client's preferences.
aa8173
 
aa8173
+=item B<-krb5svc service>
aa8173
+
aa8173
+the Kerberos service name to use (default "host"). This means s_server
aa8173
+will expect a ticket for the principal I<service>/hostname@REALM, and will
aa8173
+need keys for that principal in its keytab.
aa8173
+
aa8173
+=item B<-keytab filename>
aa8173
+
aa8173
+the Kerberos "keytab" (key table) file, containing keys for the s_server
aa8173
+service principal (Kerberos identity; see -krb5svc).
aa8173
+
aa8173
 =item B<-tlsextdebug>
aa8173
 
aa8173
 print out a hex dump of any TLS extensions received from the server.