Interestingly the german lawyers association build a software that does nearly this. Just with a small design change that made it a total flaw:
To communicate out of a https secured web mailer to a local IP and Port where a security card reader driver would respond they registered bealocalhost.de which resolves to 127.0.0.1. To prevent mixed content errors they then shipped the private key for a https certificate for bealocalhost compiled into the card reader driver.
Obviously after someone noticed that the cert got instantly revoked...