<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://k5wiki.test.kerberos.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nerdsta</id>
		<title>K5Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://k5wiki.test.kerberos.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nerdsta"/>
		<link rel="alternate" type="text/html" href="https://k5wiki.test.kerberos.org/wiki/Special:Contributions/Nerdsta"/>
		<updated>2026-05-14T18:53:25Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.4</generator>

	<entry>
		<id>https://k5wiki.test.kerberos.org/wiki?title=Pkinit_configuration&amp;diff=3919</id>
		<title>Pkinit configuration</title>
		<link rel="alternate" type="text/html" href="https://k5wiki.test.kerberos.org/wiki?title=Pkinit_configuration&amp;diff=3919"/>
				<updated>2011-08-12T20:23:36Z</updated>
		
		<summary type="html">&lt;p&gt;Nerdsta: /* Smart card configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Pkinit''' provides support  for using public-key authentication with Kerberos.  Pkinit is useful in the following situations:&lt;br /&gt;
# Using smart cards for Kerberos authentication&lt;br /&gt;
# Authentication based on soft tokens (or certificates stored on a computer) instead of passwords&lt;br /&gt;
# In conjunction with [[anonymous kerberos]] and [[Projects/FAST | FAST]] protecting password exchanges to remove the possibility of [[dictionary attacks]]&lt;br /&gt;
&lt;br /&gt;
This article describes minimal Pkinit configuration  for a KDC and clients.  It assumes you already have a Kerberos realm functioning and that you have the &amp;lt;tt&amp;gt;openssl&amp;lt;/tt&amp;gt; command available.&lt;br /&gt;
&lt;br /&gt;
The following  steps are involved:&lt;br /&gt;
# Setting up a certificate authority&lt;br /&gt;
# Generating a KDC certificate&lt;br /&gt;
# Generating client certificates&lt;br /&gt;
# Configuring the KDC and clients&lt;br /&gt;
# Testing&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
Pkinit requires a public key infrastructure.  The simplest use of&lt;br /&gt;
Pkinit ([[anonymous kerberos]]) requires a certificate authority (CA)&lt;br /&gt;
certificate and a KDC certificate.  The certificate authority&lt;br /&gt;
certificate is known by all clients; any certificates signed by this&lt;br /&gt;
certificate are trusted by the clients.  The KDC certificate is signed&lt;br /&gt;
by the certificate authority certificate (and thus trusted by the&lt;br /&gt;
clients) and identifies the KDC.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If Pkinit is used with smart cards or for other forms of user authentication, then each user will need a certificate as well.&lt;br /&gt;
&lt;br /&gt;
This document discusses how to set up Pkinit for the EXAMPLE.COM realm by hand.  This sort of by-hand setup may be appropriate for anonymous usage.  However if a realm is going to provide certificates to each client then some sort of automated certificate authority will be required to manage certificates.  Configuring an automated certificate authority will depend on what certificate authority is chosen.&lt;br /&gt;
&lt;br /&gt;
== Generating the certificate authority certificate ==&lt;br /&gt;
&lt;br /&gt;
In this document we will use OpenSSL to generate a simple self-signed certificate to use for the certificate authority.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, generate a private key:&lt;br /&gt;
&amp;lt;pre&amp;gt; openssl genrsa -out cakey.pem 2048 &amp;lt;/pre&amp;gt;&lt;br /&gt;
This will generate a 2048-bit RSA key and write it to file &amp;lt;tt&amp;gt;cakey.pem&amp;lt;/tt&amp;gt;.  In a production environment, this private key should be carefully protected.&lt;br /&gt;
Now, generate the CA certificate:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openssl req -key cakey.pem -new -x509 -out cacert.pem&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This command will ask for the name of the CA and output a CA certificate into &amp;lt;tt&amp;gt;cacert.pem&amp;lt;/tt&amp;gt; using the previously generated key.&lt;br /&gt;
&lt;br /&gt;
== Generating Kerberos certificates ==&lt;br /&gt;
&lt;br /&gt;
Kerberos certificates take advantage of two uncommon features of&lt;br /&gt;
certificates.  First, an extended key usage is used to indicate that&lt;br /&gt;
the certificate should be used with Pkinit.  An extended key usage is&lt;br /&gt;
an object identifier placed in a certificate to indicate what the&lt;br /&gt;
public key should be used for.  Secondly, an otherName form of a&lt;br /&gt;
subjectAlternativeName is used to describe the Kerberos principal&lt;br /&gt;
associated with the certificate.  An otherName is a way of including&lt;br /&gt;
types of names in certificates that were not part of the original&lt;br /&gt;
X.509 architecture.  Unfortunately, including these elements in a&lt;br /&gt;
certificate requires the use of an OpenSSL extensions file.  This&lt;br /&gt;
file provides configuration for the certificate generation process.  However the mechanisms for providing user data such as the name of the realm and the  client principal to the otherName component are primitive.&lt;br /&gt;
&lt;br /&gt;
This article includes a sample OpenSSL extensions file; see&lt;br /&gt;
[[#Extensions file]].  Paste that section of the article into a filed called &amp;lt;tt&amp;gt;pkinit_extensions&amp;lt;/tt&amp;gt;.  That file uses environment variables to set the&lt;br /&gt;
client and realm name.&lt;br /&gt;
&lt;br /&gt;
=== Generating KDC certificate ===&lt;br /&gt;
&lt;br /&gt;
First, generate the KDC key:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openssl genrsa -out kdckey.pem 2048 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then,  generate a certificate request&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openssl req -new -out kdc.req -key kdckey.pem&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Enter in the KDC name information.&lt;br /&gt;
To generate the certificate:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
REALM=EXAMPLE.COM; export REALM&lt;br /&gt;
CLIENT=&amp;lt;kdc-name.example.com&amp;gt;; export CLIENT&lt;br /&gt;
&lt;br /&gt;
openssl x509 -req -in kdc.req -CAkey cakey.pem -CA cacert.pem -out kdc.pem -extfile pkinit_extensions -extensions kdc_cert -CAcreateserial&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will generate a certificate, &amp;lt;tt&amp;gt;kdc.pem&amp;lt;/tt&amp;gt;, for the KDC.  The&lt;br /&gt;
first two lines set environment variables used by the extensions&lt;br /&gt;
file. The &amp;lt;i&amp;gt;REALM&amp;lt;/i&amp;gt; variable should be set to the name of your&lt;br /&gt;
realm.&lt;br /&gt;
&lt;br /&gt;
=== Generating client certificates ===&lt;br /&gt;
&lt;br /&gt;
For use with anonymous Kerberos, no additional certificates are needed.  For other uses of Pkinit, generate a certificate for each client.  Typically on the client machine, the private key is generated:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openssl genrsa -out clientkey.pem 2048&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The certificate request is also typically generated on the client machine:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openssl req -new -key clientkey.pem -out client.req&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;client.req&amp;lt;/tt&amp;gt; file needs to be copied to the machine with the certificate authority key.  Then, sign the certificate:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
REALM=EXAMPLE.COM; export REALM&lt;br /&gt;
CLIENT=alice; export CLIENT&lt;br /&gt;
openssl x509 -CAkey cakey.pem -CA cacert.pem -req -in client.req -extensions client_cert -extfile pkinit_extensions  -out client.pem&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
That will sign a certificate for &amp;lt;tt&amp;gt;alice@EXAMPLE.COM&amp;lt;/tt&amp;gt;.  The resulting &amp;lt;tt&amp;gt;client.pem&amp;lt;/tt&amp;gt; needs to be copied back to the client.&lt;br /&gt;
&lt;br /&gt;
== Configuring a KDC ==&lt;br /&gt;
Insert the following entries into the &amp;lt;i&amp;gt;kdcdefaults&amp;lt;/i&amp;gt; or a &amp;lt;i&amp;gt;realms&amp;lt;/i&amp;gt; section of the &amp;lt;tt&amp;gt;kdc.conf&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;krb5.conf&amp;lt;/tt&amp;gt; used by the KDC:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pkinit_identity = FILE:/var/lib/krb5kdc/kdc.pem,/var/lib/krb5kdc/kdckey.pem&lt;br /&gt;
pkinit_anchors = FILE:/var/lib/krb5kdc/cacert.pem&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Of course, adjust the directory to where the files are stored on your system.&lt;br /&gt;
Then, for each client principal that uses pkinit, set the &amp;lt;i&amp;gt;requires_preauth&amp;lt;/i&amp;gt; attribute from within &amp;lt;b&amp;gt;kadmin&amp;lt;/b&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modprinc +requires_preauth alice@EXAMPLE.COM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring a client ==&lt;br /&gt;
Add the following to the appropriate realm section of &amp;lt;tt&amp;gt;krb5.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[realms]&lt;br /&gt;
	EXAMPLE.COM = {&lt;br /&gt;
		    pkinit_anchors = FILE:/etc/krb5/cacert.pem&lt;br /&gt;
&lt;br /&gt;
		    pkinit_identities = FILE:/etc/krb5/client.pem,/etc/krb5/clientkey.pem&lt;br /&gt;
		    		    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Of course, &amp;lt;tt&amp;gt;clientkey.pem&amp;lt;/tt&amp;gt; needs to be protected .&lt;br /&gt;
After this point, using &amp;lt;b&amp;gt;kinit&amp;lt;/b&amp;gt; as the appropriate client principal should not require a password.&lt;br /&gt;
&lt;br /&gt;
== Advanced Configuration ==&lt;br /&gt;
=== Including pkinit options in a certificate request ===&lt;br /&gt;
Note that in the above example, the client name was not actually set&lt;br /&gt;
		    		    in the certificate request but was&lt;br /&gt;
		    		    set when the certificate was&lt;br /&gt;
		    		    generated.  In a production&lt;br /&gt;
		    		    situation, it would be desirable&lt;br /&gt;
		    		    to include the client name in a&lt;br /&gt;
		    		    certificate request.  There is an&lt;br /&gt;
		    		    option to do this: the&lt;br /&gt;
		    		    &amp;lt;b&amp;gt;-extenios&amp;lt;/b&amp;gt; option to the&lt;br /&gt;
		    		    &amp;lt;b&amp;gt;openssl req&amp;lt;/b&amp;gt; command is&lt;br /&gt;
		    		    intended for this purpose.&lt;br /&gt;
		    		    Unfortunately, the &amp;lt;b&amp;gt;openssl&lt;br /&gt;
		    		    req&amp;lt;/b&amp;gt; command does not have a&lt;br /&gt;
		    		    &amp;lt;b&amp;gt;-extfile&amp;lt;/b&amp;gt; option.  It seems&lt;br /&gt;
		    		    that a special file for input to&lt;br /&gt;
		    		    the &amp;lt;b&amp;gt;-config&amp;lt;/b&amp;gt; option could be&lt;br /&gt;
		    		    constructed to accomplish this. &lt;br /&gt;
&lt;br /&gt;
In theory, if the options were included in the certificate request,&lt;br /&gt;
then  a traditional certificate authority could be used to issue the&lt;br /&gt;
certificate.  Common practice is not to copy the requested extensions&lt;br /&gt;
into the issued certificate, so special configuration would probably&lt;br /&gt;
be required on the part of the certificate authority.&lt;br /&gt;
&lt;br /&gt;
=== Client identity on the command line ===&lt;br /&gt;
The &amp;lt;b&amp;gt;-X X509_user_identity&amp;lt;/b&amp;gt; option to &amp;lt;b&amp;gt;kinit&amp;lt;/b&amp;gt; allows users&lt;br /&gt;
to specify what Pkinit idenity and key should be used.  It provides an&lt;br /&gt;
alternative to specifying this information in &amp;lt;tt&amp;gt;krb5.conf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Smart card configuration ===&lt;br /&gt;
The [http://web.mit.edu/Kerberos/krb5-1.9/krb5-1.9.1/doc/krb5-admin.html#pkinit-client-options Kerberos administration manual]&lt;br /&gt;
describes how to configure Pkinit to use PKCS11 smart cards  and how to configure the selection of the correct identity.&lt;br /&gt;
&lt;br /&gt;
== Debugging Pkinit ==&lt;br /&gt;
By default, the MIT Kerberos Pkinit plugin does not support debugging output.  Debugging can be enabled but requires changing the source and rebuilding the plugin.  Add the following line to the top of &amp;lt;tt&amp;gt;src/plugins/preauth/pkinit.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define DEBUG&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, rebuild the sources.  Copy the generated &amp;lt;tt&amp;gt;pkinit.so&amp;lt;/tt&amp;gt; into place to get debugging output.&lt;br /&gt;
==Extensions file==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[ kdc_cert ]&lt;br /&gt;
basicConstraints=CA:FALSE&lt;br /&gt;
&lt;br /&gt;
# Here are some examples of the usage of nsCertType. If it is omitted&lt;br /&gt;
keyUsage = nonRepudiation, digitalSignature, keyEncipherment, keyAgreement&lt;br /&gt;
&lt;br /&gt;
#Pkinit EKU&lt;br /&gt;
extendedKeyUsage = 1.3.6.1.5.2.3.5&lt;br /&gt;
&lt;br /&gt;
subjectKeyIdentifier=hash&lt;br /&gt;
authorityKeyIdentifier=keyid,issuer&lt;br /&gt;
&lt;br /&gt;
# Copy subject details&lt;br /&gt;
&lt;br /&gt;
issuerAltName=issuer:copy&lt;br /&gt;
&lt;br /&gt;
# Add id-pkinit-san (pkinit subjectAlternativeName)&lt;br /&gt;
subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:kdc_princ_name&lt;br /&gt;
&lt;br /&gt;
[kdc_princ_name]&lt;br /&gt;
realm = EXP:0, GeneralString:${ENV::REALM}&lt;br /&gt;
principal_name = EXP:1, SEQUENCE:kdc_principal_seq&lt;br /&gt;
&lt;br /&gt;
[kdc_principal_seq]&lt;br /&gt;
name_type = EXP:0, INTEGER:1&lt;br /&gt;
name_string = EXP:1, SEQUENCE:kdc_principals&lt;br /&gt;
&lt;br /&gt;
[kdc_principals]&lt;br /&gt;
princ1 = GeneralString:krbtgt&lt;br /&gt;
princ2 = GeneralString:${ENV::REALM}&lt;br /&gt;
&lt;br /&gt;
[ client_cert ]&lt;br /&gt;
&lt;br /&gt;
# These extensions are added when 'ca' signs a request.&lt;br /&gt;
&lt;br /&gt;
basicConstraints=CA:FALSE&lt;br /&gt;
&lt;br /&gt;
keyUsage = digitalSignature, keyEncipherment, keyAgreement&lt;br /&gt;
&lt;br /&gt;
extendedKeyUsage =  1.3.6.1.5.2.3.4&lt;br /&gt;
subjectKeyIdentifier=hash&lt;br /&gt;
authorityKeyIdentifier=keyid,issuer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:princ_name&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Copy subject details&lt;br /&gt;
&lt;br /&gt;
issuerAltName=issuer:copy&lt;br /&gt;
&lt;br /&gt;
[princ_name]&lt;br /&gt;
realm = EXP:0, GeneralString:${ENV::REALM}&lt;br /&gt;
principal_name = EXP:1, SEQUENCE:principal_seq&lt;br /&gt;
&lt;br /&gt;
[principal_seq]&lt;br /&gt;
name_type = EXP:0, INTEGER:1&lt;br /&gt;
name_string = EXP:1, SEQUENCE:principals&lt;br /&gt;
&lt;br /&gt;
[principals]&lt;br /&gt;
princ1 = GeneralString:${ENV::CLIENT}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nerdsta</name></author>	</entry>

	</feed>