Blame SOURCES/openssl-1.0.2j-krb5keytab.patch

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