<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="https://forum.yubico.com/feed.php?f=35&amp;t=2557" />

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2017-02-07T16:40:08+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=35&amp;t=2557</id>
<entry>
<author><name><![CDATA[wibou]]></name></author>
<updated>2017-02-07T16:40:08+01:00</updated>
<published>2017-02-07T16:40:08+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=2557&amp;p=9356#p9356</id>
<link href="https://forum.yubico.com/viewtopic.php?t=2557&amp;p=9356#p9356"/>
<title type="html"><![CDATA[[QUESTION] Using PIV PKCS#11 for VPN under Windows]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=2557&amp;p=9356#p9356"><![CDATA[
Hello,<br /><br />To support an old VPN setup we have in-house, I need to use Yubikey 4 PIV to store PKCS#11 certificate. Those are then read by OpenVPN.<br />That <a href="https://forum.yubico.com/viewtopic.php?f=26&amp;t=2124" class="postlink">post</a> was very helpful and it works quite well on Linux machines<br /><br />However, I cannot get it to works under Windows. <br />I installed the latest release of OpenSC for Windows (0.16.0, dated Jun 3 2016... a bit old?). OpenVPN installed is of version 2.4.0 x86_64-w64-mingw32.<br />The key is a Yubikey 4 (firmware is 4.3.3) configured in OTP/U2F/CCID composite mode. The certificates are already present (it was setuped on a Linux box). <br /><br />When I try to use OpenVPN to list the certificate, OpenVPN seems to load opensc-pkcs11 driver just fine but it sees nothing:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">C:\Users\wfb&gt;OpenVPN --verb 7 --show-pkcs11-ids C:/Windows/System32/opensc-pkcs11.dll<br />Tue Feb 07 10:21:33 2017 us=433605 PKCS#11: Adding provider 'C:/Windows/System32/opensc-pkcs11.dll'-'C:/Windows/System32/opensc-pkcs11.dll'<br />Tue Feb 07 10:21:33 2017 us=464805 PKCS#11: Provider 'C:/Windows/System32/opensc-pkcs11.dll' added rv=0-'CKR_OK'<br /><br />The following objects are available for use.<br />Each object shown below may be used as parameter to<br />--pkcs11-id option please remember to use single quote mark.<br />Tue Feb 07 10:21:33 2017 us=464805 PKCS#11: Terminating openssl<br />Tue Feb 07 10:21:33 2017 us=464805 PKCS#11: Removing providers<br />Tue Feb 07 10:21:33 2017 us=464805 PKCS#11: Removing provider 'C:/Windows/System32/opensc-pkcs11.dll'<br />Tue Feb 07 10:21:33 2017 us=464805 PKCS#11: Releasing sessions<br />Tue Feb 07 10:21:33 2017 us=464805 PKCS#11: Terminating slotevent<br />Tue Feb 07 10:21:33 2017 us=464805 PKCS#11: Marking as uninitialized<br /></div><br /><br />On Linux, same key, same command (with Linux .so obviously):<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">wibou ~ $ openvpn --verb 7 --show-pkcs11-ids /usr/lib64/opensc-pkcs11.so<br />Tue Feb  7 10:37:03 2017 us=516719 PKCS#11: Adding provider '/usr/lib64/opensc-pkcs11.so'-'/usr/lib64/opensc-pkcs11.so'<br />Tue Feb  7 10:37:03 2017 us=524160 PKCS#11: Provider '/usr/lib64/opensc-pkcs11.so' added rv=0-'CKR_OK'<br />Tue Feb  7 10:37:03 2017 us=608454 PKCS#11: Creating a new session<br />Tue Feb  7 10:37:03 2017 us=608513 PKCS#11: Get certificate attributes failed: 179:'CKR_SESSION_HANDLE_INVALID'<br /><br />The following objects are available for use.<br />Each object shown below may be used as parameter to<br />--pkcs11-id option please remember to use single quote mark.<br />Tue Feb  7 10:37:03 2017 us=609156 PKCS#11: Using cached session<br /><br />Certificate<br />       DN:             C=CA, ST=Quebec, L=Montreal, O=MY ORGANISATION, CN=MY NAME, emailAddress=MY_EMAIL@EMAIL.COM<br />       Serial:         1A<br />       Serialized id:  piv_II/PKCS\x2315\x20emulated/00000000/PIV_II\x20\x28PIV\x20Card\x20Holder\x20pin\x29/02<br />Tue Feb  7 10:37:03 2017 us=609495 PKCS#11: Terminating openssl<br />Tue Feb  7 10:37:03 2017 us=609527 PKCS#11: Removing providers<br />Tue Feb  7 10:37:03 2017 us=609556 PKCS#11: Removing provider '/usr/lib64/opensc-pkcs11.so'<br />Tue Feb  7 10:37:03 2017 us=610466 PKCS#11: Releasing sessions<br />Tue Feb  7 10:37:03 2017 us=610508 PKCS#11: Marking as uninitialized<br /></div><br />(The error about 'CKR_SESSION_HANDLE_INVALID' is weird but it does not seem to matter).<br /><br />There seems to be some people reporting various success:<br /><a href="https://community.openvpn.net/openvpn/ticket/740" class="postlink">https://community.openvpn.net/openvpn/ticket/740</a><br /><a href="https://www.sparklabs.com/forum/viewtopic.php?f=9&amp;t=2253" class="postlink">https://www.sparklabs.com/forum/viewtopic.php?f=9&amp;t=2253</a><br /><br />But it's never quite clear how they did it and what they were using.<br />Since OpenSC release 0.16.0 is a bit old, I'm beginning to suspect it could only work on the latest (unreleased, unpackaged) development branch.<br /><br />Did anyone here had some success storing PKCS#11 in PIV slots on Windows? <br />Any hint?<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=4672">wibou</a> — Tue Feb 07, 2017 4:40 pm</p><hr />
]]></content>
</entry>
</feed>