Skip to main content

Hacking on ThinPro: Fixing EAP-TLS

I ran into a problem awhile ago which was causing ThinPro to strip an issuing CA out of a certificate chain. My investigation started when I noticed that wireless authentication for my test device was failing in certain areas. Naturally, I wanted to see what was going on with the wireless NIC, so I ran grep -i wlan0 /var/log/syslog to see if I could catch why it was so unhappy. I found the following information:

wlan0: CTRL-EVENT-EAP-TLS-CERT-ERROR reason=1 depth=0 subject='/C=US/ST=NY/L=HomeBase/O=NewbAdmin/OU=DummyOU/CN=DummyDev' err='unable to get local issuer certificate'
...
SSL: SSL3 alert: write (local SSL3 detected an error):fatal:unknown CA
EAP: Status notification: local TLS alert (param=unknown CA)
...
OpenSSL: openssl_handshake - SSL_connect error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

Seeing the unknown CA alert, I thought maybe I had neglected to add a certificate, so I checked ThinPro's certificate control panel, but I didn't see anything missing. Next, I sent a SCEP enrollment task from HP Device Manager (HPDM) to see if ThinPro was breaking something during the enrollment process. Here's a screenshot of the chain before SCEP enrollment:

The purpose of a PKI certificate is to be public, but I used dummy certificates here anyway because why not.

-----BEGIN CERTIFICATE-----
MIIFVTCCAz2gAwIBAgIQMuoogkKW+69KyHGNg2JOcjANBgkqhkiG9w0BAQsFADA9
MRMwEQYKCZImiZPyLGQBGRYDT1JHMRQwEgYKCZImiZPyLGQBGRYEQ1JIQzEQMA4G
A1UEAxMHQ0gtUk9PVDAeFw0xNjEwMDcxODE5MjVaFw0zNjEwMDcxODI5MjNaMD0x
EzARBgoJkiaJk/IsZAEZFgNPUkcxFDASBgoJkiaJk/IsZAEZFgRDUkhDMRAwDgYD
VQQDEwdDSC1ST09UMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvMJX
1O1aq68wauXbgr6lz5WsE85wZJGSZL3Uifx7QbWR8fsyY0avwUVXjXh98Cu8vfP1
Uqr4/ZsWsQQwNBnuaZQ5oc7+hpDMpJ0EOdhzG4sTj855H1xPgNvGEKdiMi2BE9OT
ZBTX1M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cDovL3BraWlzc3V
cXCiI327GBS9nj0ei2vXXcISDkvYTO2okPyeajrYAfAd2e4LHFlyGS8ildSVgNya
JxFAG9xAdJXG4+8A0VYvV+2ABkxzS8c9cZeSL56DXu3zD/gAGw6qvU1kT/zGhUtw
BjaZPehg96YqZghtWQgekF5X06rVKLDfUr5zmaEA5f/ECfHZQ7Pv+T9GfBH5VQ+z
vULY4KPKVjci/q9d6Qt1jN1SCBf0D/jHQjsFYFRAAE22MKaRxfNNuNsmF6iStbSg
kTPaahdnOIjD3+ejSu2KSJPvOqFmJq+jMoYwQUhJI1/eDZRrKxtp4AUF23D3ptQg
DGaPhJQzcpRQERN9PGGiq6WI4sMuIXBBuz2IThU3wCqbciaphFqBwTc=
-----END CERTIFICATE-----

As you can see, there are clearly two certificates in this chain, but after running the SCEP enrollment task, I found this:

-----BEGIN CERTIFICATE-----
MIIFVTCCAz2gAwIBAgIQMuoogkKW+69KyHGNg2JOcjANBgkqhkiG9w0BAQsFADA9
MRMwEQYKCZImiZPyLGQBGRYDT1JHMRQwEgYKCZImiZPyLGQBGRYEQ1JIQzEQMA4G
A1UEAxMHQ0gtUk9PVDAeFw0xNjEwMDcxODE5MjVaFw0zNjEwMDcxODI5MjNaMD0x
EzARBgoJkiaJk/IsZAEZFgNPUkcxFDASBgoJkiaJk/IsZAEZFgRDUkhDMRAwDgYD
VQQDEwdDSC1ST09UMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvMJX
1O1aq68wauXbgr6lz5WsE85wZJGSZL3Uifx7QbWR8fsyY0avwUVXjXh98Cu8vfP1
Uqr4/ZsWsQQwNBnuaZQ5oc7+hpDMpJ0EOdhzG4sTj855H1xPgNvGEKdiMi2BE9OT
ZBTX1MDTM3tOuBX8lWPPQDIDJrelkjfioeur3908rdofjdslkg12hEE1eBnaNYRu
WoSxMqgEZd/f0/KDmSlWS6anx1rg/oX5SJY3Ct5IUYzCNkFdei7IBa9a9yUoomHb
aAwcrcGuZkmmZHry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llBBU8BSbI
06EkoAIiJrIWl3lFqwpeWHf2/FCJwiKxXsevzYxjQBrbXpfzhE+fpSufzui7TwcG
AgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFEpGDKYhVaVTF09zkyBGAeJi
DUzufkNofABNR7UA5LHEhQFy8smVlxRdVA==
-----END CERTIFICATE-----

Yup, that would certainly do it. Something happened during the SCEP enrollment process that chopped out the second certificate. Also, RUDE!

Now that I could reproduce the problem on demand, I wanted to know when the OS started behaving this way, so I started rolling back updates. I started with SP8 and confirmed the issue was still present. The problem was also still present in SP7. It wasn't until I rolled back to SP2 that I was able to confirm that certificate chain processing was behaving correctly. So what changed?

Unfortunately, there wasn't anything helpful in the service pack release notes, so I had to manually update the OS and check the update log (hurray....) The first thing that caught my eye was that the hptc-cert-mgr package had been updated.

image.png

I found the /lib/hptc-cert-mgr/folder and took a look at the contents.

hptc-cert-mgr folder.png

Hey, look at that! There's a script in there called certmgr-apply. That sure sounds promising. I compared the same script from SP2 and SP9. After confirming that the script had indeed been modified between versions, I reinstalled the copy from SP2 and re-ran the SCEP enrollment task. To my great relief, ThinPro was no longer breaking the chain during enrollment.

My experience with vendor support has been that more information = more better, so I decided to dig a little deeper before reporting the bug to HP. I compared the two copies of the certmgr-apply script and saw that there were only a few changes. I'll spare you the boring trip through most of the code, but my particular problem stems from this block here:

else
    openssl x509 -in $CA_CERT_FILE -inform PEM -out $DEST_FILE.crt -outform PEM
    if [ "$?" = "0" ]; then
        echo "+${LOCAL_CERT_STORE}${DEST_FILE}.crt" >> ${CERTMGR_CHANGE_FILE}
        rm $CA_CERT_FILE
    fi
fi

This part of the script basically extracts the first certificate in the chain, outputs it to a new file, and then deletes the original chain. I'm not entirely sure what ultimate purpose this serves, but there is a very similar block of code with the same openssl command in both versions of the script, so I'll assume that it's at least trying to do something important.

The critical difference for me is actually closer to the top where some variables get declared. Here's the SP2 copy:

SUPPORT_SUFFIX=".crt .CRT"
UN_SUPPORT_SUFFIX=".pem .PEM"
TO_CONVERT_SUFFIX=".der .DER .p7b .P7B .p7c .P7C .cer .CER"

And here's the SP7 copy:

SUPPORT_SUFFIX=""
UN_SUPPORT_SUFFIX=".pem .PEM"
TO_CONVERT_SUFFIX=".crt .CRT .der .DER .p7b .P7B .p7c .P7C .cer .CER"

My walk through the script revealed that the removal of .crt from theĀ SUPPORT_SUFFIX variable causes the certificate chain to be processed by the broken openssl command. The openssl command causes the issuing CA to be stripped out of the chain, and that results in ThinPro refusing to connect to the wireless network.

I hope someone out there on them internets finds this useful or at least mildly educational. Navigating a problem like this is rarely as quick or straightforward as it seems in the write-up, so remember to be patient and take it one step at a time.

Thanks for reading!