<div dir="ltr">On Thu, Feb 11, 2016 at 1:42 AM, Sumit Bose <span dir="ltr"><<a href="mailto:sbose@redhat.com" target="_blank">sbose@redhat.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On Wed, Feb 10, 2016 at 11:07:14PM +1100, Nik Lam wrote:<br>
> On Wed, Feb 10, 2016 at 7:43 PM, Sumit Bose <<a href="mailto:sbose@redhat.com">sbose@redhat.com</a>> wrote:<br>
><br>
> > On Wed, Feb 10, 2016 at 12:07:45PM +1100, Nik Lam wrote:<br>
> > > On Wed, Feb 10, 2016 at 3:04 AM, Sumit Bose <<a href="mailto:sbose@redhat.com">sbose@redhat.com</a>> wrote:<br>
> > ><br>
> > > > On Wed, Feb 10, 2016 at 02:08:55AM +1100, Nik Lam wrote:<br>
> > > > > On Mon, Feb 8, 2016 at 11:53 PM, Sumit Bose <<a href="mailto:sbose@redhat.com">sbose@redhat.com</a>><br>
> > wrote:<br>
> > > > ><br>
> > > > > > On Thu, Feb 04, 2016 at 07:25:29PM +1100, Nik Lam wrote:<br>
> > > > > > > On Wed, Feb 3, 2016 at 8:08 PM, Sumit Bose <<a href="mailto:sbose@redhat.com">sbose@redhat.com</a>><br>
> > wrote:<br>
> > > > > > ><br>
> > > > > > > > On Wed, Feb 03, 2016 at 10:29:49AM +1100, Nik Lam wrote:<br>
> > > > > > > > > Hello,<br>
> > > > > > > > ><br>
> > > > > > > > > I installed ipa-server on Centos 7.1 and later did and<br>
> > upgrade<br>
> > > > of the<br>
> > > > > > > > whole<br>
> > > > > > > > > system to Centos 7.2.<br>
> > > > > > > > ><br>
> > > > > > > > > I think the FreeIPA version changed from 4.1.0 to 4.2.0<br>
> > between<br>
> > > > these<br>
> > > > > > > > > Centos/RHEL minor releases.<br>
> > > > > > > > ><br>
> > > > > > > > > We'd now like to try integrating with a 2FA provider via a<br>
> > radius<br>
> > > > > > proxy<br>
> > > > > > > > and<br>
> > > > > > > > > want to use anonymous PKINIT to secure the initial<br>
> > communications<br>
> > > > > > between<br>
> > > > > > > > > the client and the KDC.<br>
> > > > > > > > ><br>
> > > > > > > > > We've tried following the MIT Kerberos PKINIT configuration<br>
> > > > > > documentation<br>
> > > > > > > > ><br>
> > > > > > > > ><br>
> > <a href="http://web.mit.edu/kerberos/krb5-1.14/doc/admin/pkinit.html" rel="noreferrer" target="_blank">http://web.mit.edu/kerberos/krb5-1.14/doc/admin/pkinit.html</a><br>
> > > > > > > > ><br>
> > > > > > > > > generating our own certs manually with openssl but haven't<br>
> > had<br>
> > > > any<br>
> > > > > > luck.<br>
> > > > > > > > > We're seeing this in the kdc log:<br>
> > > > > > > > ><br>
> > > > > > > > >     preauth pkinit failed to initialize: No realms configured<br>
> > > > > > correctly<br>
> > > > > > > > for<br>
> > > > > > > > > pkinit support<br>
> > > > > > > ><br>
> > > > > > > > Which changes did you apply to krb5.conf? Did you use the IPA<br>
> > CA to<br>
> > > > > > sign<br>
> > > > > > > > the certificate or some other CA?<br>
> > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > I've noticed there are many new pkinit-related options that<br>
> > have<br>
> > > > been<br>
> > > > > > > > added<br>
> > > > > > > > > to the ipa-server-install script in 4.2.0, so it looks like<br>
> > > > PKINIT is<br>
> > > > > > > > > available in this version of FreeIPA. Is that the case?<br>
> > > > > > > ><br>
> > > > > > > > Which options are you referring to?<br>
> > > > > > > ><br>
> > > > > > > > bye,<br>
> > > > > > > > Sumit<br>
> > > > > > > ><br>
> > > > > > > > ><br>
> > > > > > > > > And if it is, what is the recommended way to enable it given<br>
> > > > that it<br>
> > > > > > > > seems<br>
> > > > > > > > > to have been disabled in the original install that I did? Or<br>
> > > > would it<br>
> > > > > > > > just<br>
> > > > > > > > > be easier to start from scratch with a 4.2.0<br>
> > ipa-server-install?<br>
> > > > > > (It's a<br>
> > > > > > > > > test instance that doesn't have too much in it - it will<br>
> > take a<br>
> > > > > > several<br>
> > > > > > > > > hours to rebuild from scratch.)<br>
> > > > > > > > ><br>
> > > > > > > > > Regards,<br>
> > > > > > > > ><br>
> > > > > > > > > Nik<br>
> > > > > > > ><br>
> > > > > > > ><br>
> > > > > > > ><br>
> > > > > > > Thanks Sumit.<br>
> > > > > > ><br>
> > > > > > > It sounds like PKINIT is available but clearly I'm doing it<br>
> > wrong.<br>
> > > > > > ><br>
> > > > > > >  > Which changes did you apply to krb5.conf? Did you use the IPA<br>
> > CA<br>
> > > > to<br>
> > > > > > sign<br>
> > > > > > > the certificate or some other CA?<br>
> > > > > > ><br>
> > > > > > > Actually, I modified the kdc.conf file - placed the kdc.pem,<br>
> > > > kdckey.pem<br>
> > > > > > and<br>
> > > > > > > cacert.pem files in /var/kerberos/krb5kdc/ that I generated via<br>
> > > > openssl<br>
> > > > > > > commands in the MIT Kerberos documentation. The only change to<br>
> > > > kdc.conf<br>
> > > > > > > file was to append the location of the kdckey.pem file to<br>
> > > > > > pkinit_identity.<br>
> > > > > > ><br>
> > > > > > >   pkinit_identity = FILE:/var/kerberos/krb5kdc/kdc.pem<br>
> > > > > > >   pkinit_anchors = FILE:/var/kerberos/krb5kdc/cacert.pem<br>
> > > > > > ><br>
> > > > > > > became<br>
> > > > > > ><br>
> > > > > > >   pkinit_identity =<br>
> > > > > > ><br>
> > FILE:/var/kerberos/krb5kdc/kdc.pem,/var/kerberos/krb5kdc/kdckey.pem<br>
> > > > > > >   pkinit_anchors = FILE:/var/kerberos/krb5kdc/cacert.pem<br>
> > > > > > ><br>
> > > > > > > Should I have been modifying krb5.conf instead? It aslo sounds<br>
> > like I<br>
> > > > > > need<br>
> > > > > ><br>
> > > > > > no, kdc.conf is the right place, I actually meant kdc.conf but<br>
> > > > > > accidentially types krb5.conf.<br>
> > > > > ><br>
> > > > > > > to use a certificate signed by the IPAs CA - is this something<br>
> > that<br>
> > > > > > should<br>
> > > > > > > be generated using ipa-getcert? Or do I just find the IPA CA's<br>
> > > > private<br>
> > > > > > key<br>
> > > > > > > and use openssl following the MIT Kerberos documentation?<br>
> > > > > > ><br>
> > > > > > >  > Which options are you referring to?<br>
> > > > > > ><br>
> > > > > > > When I looked at the --help text for 4.1.0 and 4.2.0 versions of<br>
> > > > > > > ipa-server-install, I noticed that 4.2.0 has these in the<br>
> > > > "certificate<br>
> > > > > > > system options":<br>
> > > > > > ><br>
> > > > > > >     --no-pkinit         disables pkinit setup steps<br>
> > > > > > ><br>
> > > > > > >     --pkinit-cert-file=FILE<br>
> > > > > > >                         File containing the Kerberos KDC SSL<br>
> > > > certificate<br>
> > > > > > and<br>
> > > > > > >                         private key<br>
> > > > > > ><br>
> > > > > > >     --pkinit-pin=PIN    The password to unlock the Kerberos KDC<br>
> > > > private<br>
> > > > > > key<br>
> > > > > > ><br>
> > > > > > >     --pkinit-cert-name=NAME<br>
> > > > > > >                         Name of the Kerberos KDC SSL certificate<br>
> > to<br>
> > > > > > install<br>
> > > > > > ><br>
> > > > > > ><br>
> > > > > > > Seeing that first one, I was a little hopeful that pkinit is<br>
> > enabled<br>
> > > > by<br>
> > > > > > > default in 4.2.0 but on a fresh install I just tried, I'm still<br>
> > > > seeing<br>
> > > > > > the<br>
> > > > > ><br>
> > > > > > no, unfortunately pkinit is currently disabled by default<br>
> > > > > ><br>
> > > > > > > following in krb5kdc.log when IPA is started up, so clearly it<br>
> > isn't.<br>
> > > > > > ><br>
> > > > > > >   (Error): preauth pkinit failed to initialize: No realms<br>
> > configured<br>
> > > > > > > correctly for pkinit support<br>
> > > > > ><br>
> > > > > > I get the same error when I put the certificate and the key into<br>
> > > > > > separate files. Can you try to put both into one and use this for<br>
> > the<br>
> > > > > > pkinit_identity option?<br>
> > > > > ><br>
> > > > > > HTH<br>
> > > > > ><br>
> > > > > > bye,<br>
> > > > > > Sumit<br>
> > > > > ><br>
> > > > ><br>
> > > > ><br>
> > > > > Thanks Sumit, it did!<br>
> > > > ><br>
> > > > > I concatenated the cert and the key into a single file and the error<br>
> > has<br>
> > > > > indeed gone away from krb5kdc.log<br>
> > > > ><br>
> > > > > The odd thing is that I can't reproduce the error by splitting into<br>
> > two<br>
> > > > > separate files and restarting ipa.service again.<br>
> > > > ><br>
> > > > > Ignoring that mystery, how do I go about setting up the<br>
> > > > WELLKNOWN/ANONYMOUS<br>
> > > > > principal?<br>
> > > > ><br>
> > > > > I'm pretty sure it's needed for anonymous pkinit:<br>
> > > > ><br>
> > > > > $ kinit<br>
> > > > > kinit: Generic preauthentication failure while getting initial<br>
> > > > credentials<br>
> > > > > $<br>
> > > > ><br>
> > > > > $ kinit -n<br>
> > > > > kinit: Client 'WELLKNOWN/<a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>' not found in<br>
> > Kerberos<br>
> > > > > database while getting initial credentials<br>
> > > > > $<br>
> > > > ><br>
> > > > > Using  kadmin per the MIT documentation doesn't seem to work<br>
> > > > (authenticated<br>
> > > > > as an IPA admin)<br>
> > > > ><br>
> > > > > # kadmin -q 'addprinc -randkey WELLKNOWN/ANONYMOUS'<br>
> > > > > Authenticating as principal admin/<a href="mailto:admin@EXAMPLE.COM">admin@EXAMPLE.COM</a> with password.<br>
> > > > > kadmin: Client not found in Kerberos database while initializing<br>
> > kadmin<br>
> > > > > interface<br>
> > > > > #<br>
> > > > ><br>
> > > > > # kadmin -q 'addprinc -randkey WELLKNOWN/ANONYMOUS' -p admin<br>
> > > > > Authenticating as principal admin with password.<br>
> > > > > Password for <a href="mailto:admin@EXAMPLE.COM">admin@EXAMPLE.COM</a>:<br>
> > > > > WARNING: no policy specified for WELLKNOWN/<a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>;<br>
> > > > > defaulting to no policy<br>
> > > > > add_principal: Operation requires ``add'' privilege while creating<br>
> > > > > "WELLKNOWN/<a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>".<br>
> > > > > #<br>
> > > ><br>
> > > > Please try<br>
> > > ><br>
> > > >     kadmin.local -x ipa-setup-override-restrictions<br>
> > > ><br>
> > > > bye,<br>
> > > > Sumit<br>
> > > ><br>
> > > ><br>
> > > Thanks Sumit.<br>
> > ><br>
> > > That seems to have worked to get the principal created.<br>
> > ><br>
> > > # kadmin.local -x ipa-setup-override-restrictions<br>
> > > Authenticating as principal admin/<a href="mailto:admin@EXAMPLE.COM">admin@EXAMPLE.COM</a> with password.<br>
> > > kadmin.local:  addprinc -randkey WELLKNOWN/ANONYMOUS<br>
> > > WARNING: no policy specified for WELLKNOWN/<a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>;<br>
> > > defaulting to no policy<br>
> > > Principal "WELLKNOWN/<a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>" created.<br>
> > > kadmin.local:  quit<br>
> > > #<br>
> > ><br>
> > > I'm no longer seeing the error from the client about 'WELLKNOWN/<br>
> > > <a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>' not found in Kerberos database.<br>
> > ><br>
> > > However, I'm being prompted for a password for the anonymous principal.<br>
> > ><br>
> > > $ kinit -n<br>
> > > Password for WELLKNOWN/<a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>:<br>
> > > kinit: Password incorrect while getting initial credentials<br>
> > > $<br>
> > ><br>
> > > That doesn't sound right to me - and indeed it doesn't provide an armor<br>
> > > cache that I can use for authenticating my client user.<br>
> ><br>
> > Can you run<br>
> ><br>
> >     KRB5_TRACE=/dev/stdout kinit -n<br>
> ><br>
> > this will show the list of preauthentication methods offered to the<br>
> > client and I would suspect that pkinit is not among of them.<br>
> ><br>
> > My guess is that there is something wrong with the certificate or the<br>
> > configuration, e.g. did you try to set pkinit_kdc_hostname to the<br>
> > hostname matching the one in the KDC certificate? Maybe<br>
> > pkinit_eku_checking = none might help as well?.<br>
> ><br>
> > To analyse this further the most easy way is an instrumented build of<br>
> > the pkinit module with debugging enabled. If you can tell me the exact<br>
> > version of your krb5-pkinit package I can prepare a build for you.<br>
> ><br>
> > HTH<br>
> ><br>
> > bye,<br>
> > Sumit<br>
> ><br>
><br>
> Thank you Sumit.<br>
><br>
> I've checked that the hostname in the KDC's cert matches what I've put in<br>
> the client's krb.conf's pkinit_hostname.<br>
><br>
> I've also tried setting pkinit_eku_checking = none in there.<br>
><br>
> $ KRB5_TRACE=/dev/stdout kinit -n<br>
> [9199] 1455105392.574916: Getting initial credentials for WELLKNOWN/<br>
> <a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a><br>
> [9199] 1455105392.575132: Sending request (186 bytes) to <a href="http://EXAMPLE.COM" rel="noreferrer" target="_blank">EXAMPLE.COM</a><br>
> [9199] 1455105392.575314: Initiating TCP connection to stream<br>
> <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105392.576513: Sending TCP request to stream <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105393.370873: Received answer (483 bytes) from stream<br>
> <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105393.370885: Terminating TCP connection to stream<br>
> <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105393.370956: Response was from master KDC<br>
> [9199] 1455105393.370977: Received error from KDC: -1765328359/Additional<br>
> pre-authentication required<br>
> [9199] 1455105393.371014: Processing preauth types: 16, 15, 14, 136, 19,<br>
> 147, 2, 133<br>
<br>
</div></div>ok, 147 means that the server added the needed preauthentication data<br>
for anonymous pkinit.<br>
<br>
Did you set<br>
<br>
   pkinit_anchors = FILE:/var/kerberos/krb5kdc/cacert.pem<br>
<br>
in /etc/krb5.conf as well becasue the client must know the CA<br>
certificate as well?<br>
<div><div class="h5"><br>
> [9199] 1455105393.371040: Selected etype info: etype aes256-cts, salt<br>
> "EXAMPLE.COMWELLKNOWNANONYMOUS", params ""<br>
> [9199] 1455105393.371046: Received cookie: MIT<br>
> Password for WELLKNOWN/<a href="mailto:ANONYMOUS@EXAMPLE.COM">ANONYMOUS@EXAMPLE.COM</a>:<br>
> [9199] 1455105400.912468: AS key obtained for encrypted timestamp:<br>
> aes256-cts/09BF<br>
> [9199] 1455105400.912546: Encrypted timestamp (for 1455105400.914484):<br>
> plain 301AA011180F32303136303231303131353634305AA10502030DF434, encrypted<br>
> DD840BC3D6F697529D987E73EDD1C9FF82FEC91A0FB408179E6FA9AF49627912BEF49BA4E4EE8FF469BED5672943592A1E7DFBBF781C1E5B<br>
> [9199] 1455105400.912576: Preauth module encrypted_timestamp (2) (real)<br>
> returned: 0/Success<br>
> [9199] 1455105400.912581: Produced preauth for next request: 133, 2<br>
> [9199] 1455105400.912601: Sending request (281 bytes) to <a href="http://EXAMPLE.COM" rel="noreferrer" target="_blank">EXAMPLE.COM</a><br>
> [9199] 1455105400.912674: Initiating TCP connection to stream<br>
> <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105400.913894: Sending TCP request to stream <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105400.937778: Received answer (197 bytes) from stream<br>
> <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105400.937788: Terminating TCP connection to stream<br>
> <a href="http://10.93.178.73:88" rel="noreferrer" target="_blank">10.93.178.73:88</a><br>
> [9199] 1455105400.937835: Response was from master KDC<br>
> [9199] 1455105400.937852: Received error from KDC: -1765328353/Decrypt<br>
> integrity check failed<br>
> kinit: Password incorrect while getting initial credentials<br>
> $<br>
><br>
> The module package we're using right now is<br>
> krb5-pkinit-1.13.2-10.el7.x86_64.<br>
<br>
</div></div>Please find the package with debugging enabled at<br>
<a href="https://kojipkgs.fedoraproject.org//work/tasks/8127/12928127/krb5-pkinit-1.13.2-10.el7sb.x86_64.rpm" rel="noreferrer" target="_blank">https://kojipkgs.fedoraproject.org//work/tasks/8127/12928127/krb5-pkinit-1.13.2-10.el7sb.x86_64.rpm</a><br>
<br>
It might be possible to install it with<br>
<br>
    rpm -Uhv --nodeps krb5-pkinit-1.13.2-10.el7sb.x86_64.rpm<br>
<br>
to get around yum's dependency checking but after testing<br>
<br>
    yum downgrade krb5-pkinit<br>
<br>
should be able to install the original version again. Please do not<br>
forget to revert to the original version, otherwise SSSD's Kerberos<br>
authentication might break because the pkinit module will print the<br>
debug messages just to stdout.<br>
<br>
As an alternative you can just extract<br>
/usr/lib64/krb5/plugins/preauth/pkinit.so with rpm2cpio from the package<br>
and replace the original one. Do not forget to make a copy of the<br>
original module in a different directory to be able to revert the<br>
change.<br>
<div class=""><div><br>
HTH<br>
<br>
bye,<br>
Sumit<br></div></div></blockquote><div><br></div><div>Thanks so much Sumit.<br><br></div><div>I've upgraded that package on both the IdM server and the (problem) client.<br><br></div><div>I haven't looked *really* closely at the logs or the trace output, but it doesn't look like I'm getting any additional output.<br><br></div><div>However, on a whim, went to another client. This time I went to check what version of krb5-pkinit was installed, and discovered it wasn't installed along with the rest of the ipa-client package dependencies.<br><br></div><div>I installed the GA version of krb5-pkinit and it all just works!<br></div><div><br>[testuser@client01-756712 ~]$ kinit -n<br>[testuser@client01-756712 ~]$<br>[testuser@client01-756712 ~]$<br>[testuser@client01-756712 ~]$ klist<br>Ticket cache: FILE:/tmp/krb5cc_842000006<br>Default principal: WELLKNOWN/ANONYMOUS@WELLKNOWN:ANONYMOUS<br><br>Valid starting       Expires              Service principal<br>02/10/2016 23:28:46  02/11/2016 23:28:46  krbtgt/<a href="mailto:EXAMPLE.COM@EXAMPLE.COM">EXAMPLE.COM@EXAMPLE.COM</a><br>[testuser@client01-756712 ~]$<br>[testuser@client01-756712 ~]$<br>[testuser@client01-756712 ~]$ kinit -T /tmp/krb5cc_842000006 testuser<br>Enter OTP Token Value: <br>[testuser@client01-756712 ~]$ <br>[testuser@client01-756712 ~]$<br>[testuser@client01-756712 ~]$ klist<br>Ticket cache: FILE:/tmp/krb5cc_842000006<br>Default principal: <a href="mailto:testuser@EXAMPLE.COM">testuser@EXAMPLE.COM</a><br><br>Valid starting       Expires              Service principal<br>02/10/2016 23:29:14  02/11/2016 23:29:07  krbtgt/<a href="mailto:EXAMPLE.COM@EXAMPLE.COM">EXAMPLE.COM@EXAMPLE.COM</a><br>[testuser@client01-756712 ~]$ <br> <br></div><div>So it looks like the absence of the krb5-pkinit package was the reason why kinit was prompting for the WELLKNOWN/ANONYMOUS password.<br><br></div><div>To confirm, all that is needed on the client's krb5.conf file is to have pkinit_anchors pointing to a copy of the belonging to the CA that was used to create the KDC's cert (which in our case was a self-generated one not freeIPA/Dogtag's one).<br></div><div><br></div><div>So, I think we've got everything we need to start using it. Thanks again for your help.<br><br></div><div>With respect to the future plans - is there anything we need to beware of in terms of our manual creation of the WELLKNOWN/ANONYMOUS principal via "kadmin.local -x ipa-setup-override-restrictions"?<br>Is freeIPA likely to have a fully-integrated anonymous PKINIT solution in the near future? You people have done such a great job of making the rest of this stuff easy and well-documented. Hats off to the developers (and Red Hat for sponsoring the project).<br><br></div><div>Cheers,<br><br>Nik<br></div><div><br></div></div><br></div></div>