Skip to content

WIP: OpenSSL PKCS#11 Engine - #8200

Closed
opensignature wants to merge 124 commits into
openssl:masterfrom
opensignature:signonly-pkcs11-engine
Closed

opensignature wants to merge 124 commits into
openssl:masterfrom
opensignature:signonly-pkcs11-engine

Conversation

@opensignature

Copy link
Copy Markdown
Contributor
Checklist
  • documentation is added or updated
  • tests are added or updated

Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
@mspncp

mspncp commented Feb 11, 2019

Copy link
Copy Markdown
Contributor

Note: @opensignature it might help to take a look at our Coding Style Guide.

Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved

@FdaSilvaYY FdaSilvaYY left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is more than these few remarks.
Some of them are applicable all along.
Better tag WIP this PR ;)

Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
Comment thread engines/e_pkcs11.c Resolved
@opensignature opensignature changed the title OpenSSL PKCS#11 Engine WIP: OpenSSL PKCS#11 Engine Feb 12, 2019
@dwmw2

dwmw2 commented Aug 23, 2019

Copy link
Copy Markdown
Contributor

Here's another test case for you.

Consider a certificate chain A → B → CA.
End-user certificate A and intermediate B are stored in a PKCS#11 token, along with the private key for A.

The server has only the CA, not the intermediate B.

Client authenticates, using a simple specifier for the cert e.g. openssl s_client -connect localhost:8443 -cert pkcs11:manufacturer=SoftHSM;object=A

The client code should automatically find the intermediate B in the same token and present it on the wire, otherwise the client certificate authentication cannot work.

This works for example with OpenConnect, when built against GnuTLS. Because of historical Cisco/OpenSSL issues we try really hard to present a full and accurate chain on the wire to prevent the server from having to piece it together for itself.

cf. http://git.infradead.org/users/dwmw2/openconnect.git/blob/HEAD:/gnutls.c#l1597
and discussion at OpenSC/libp11#297

@maxcuttins

Copy link
Copy Markdown

This feature is great!

@maxcuttins

Copy link
Copy Markdown

I got this error while testing:

openssl storeutl -engine pkcs11 'pkcs11:'
engine "pkcs11" set.
Couldn't open file or uri pkcs11:
140570496155648:error:02016002:system library:stat:No such file or directory:crypto/store/loader_file.c:827:pkcs11:

@p-steuer

Copy link
Copy Markdown
Member

If your also interested in a pkcs 11 provider, see #10265 .

We try to identify everything thats still missing to enable a pkcs11 provider implementation.

@beldmit

beldmit commented Apr 26, 2020

Copy link
Copy Markdown
Member

I'm not sure whether this solution is fork-suitable.

If you load your private key and fork afterward, the key handle has many chances to become invalid.

@opensignature

Copy link
Copy Markdown
Contributor Author

I'm not sure whether this solution is fork-suitable.

If you load your private key and fork afterward, the key handle has many chances to become invalid.

@beldmit thanks for looking at this code.
However, I would not like to take further interest in this PR for two reasons:

  1. contains RSA low level APIs which have been deprecated
  2. provider will replace engine
    the publication of openssl 3 alpha has encouraged me to resume the development of the pkcs11 provider, even there, initially I had used RSA low level APIs which I will now have to convert.

@beldmit

beldmit commented Apr 26, 2020

Copy link
Copy Markdown
Member

I'm not sure it will make you safe in the case of forking.

@t8m

t8m commented Apr 27, 2020

Copy link
Copy Markdown
Member

@opensignature Please close this one if you intend to use the provider interface instead.

@opensignature

Copy link
Copy Markdown
Contributor Author

@opensignature Please close this one if you intend to use the provider interface instead.

ok @t8m

@opensignature

Copy link
Copy Markdown
Contributor Author

I extrapolated the engine code and created a separate project.
We have discussed the code extensively in this PR and it would be a shame to lose it, so if anyone can care about the repository it is here https://github.com/opensignature/pkcs11engine
I also added a small demo.

@levitte

levitte commented Jun 10, 2020

Copy link
Copy Markdown
Member

I've added that repo on my watch list, thank you

@slontis

slontis commented Jun 10, 2020

Copy link
Copy Markdown
Member

@romen

@maxcuttins

Copy link
Copy Markdown

Do you think this will never be included in the final distribution of openssl?

@levitte

levitte commented Dec 3, 2020

Copy link
Copy Markdown
Member

Do you think this will never be included in the final distribution of openssl?

None of us are making that kind of effort for them moment, so it looks like this is going to remain an external engine/provider for the near future.
But, I'm only one guy that's looking at the current trends. The team as a whole might make a different decision at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.