Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSL_CTX_set_client_cert_engine #72881

Open
tiran opened this issue Nov 15, 2016 · 13 comments
Open

Add SSL_CTX_set_client_cert_engine #72881

tiran opened this issue Nov 15, 2016 · 13 comments
Assignees
Labels
3.13 bugs and security fixes topic-SSL type-feature A feature request or enhancement

Comments

@tiran
Copy link
Member

tiran commented Nov 15, 2016

BPO 28695
Nosy @tiran, @belolap, @Muffo, @bryan-hunt

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/tiran'
closed_at = None
created_at = <Date 2016-11-15.11:01:28.785>
labels = ['expert-SSL', 'type-bug', '3.8']
title = 'Add SSL_CTX_set_client_cert_engine'
updated_at = <Date 2018-07-31.22:18:46.537>
user = 'https://github.com/tiran'

bugs.python.org fields:

activity = <Date 2018-07-31.22:18:46.537>
actor = 'bryguy'
assignee = 'christian.heimes'
closed = False
closed_date = None
closer = None
components = ['SSL']
creation = <Date 2016-11-15.11:01:28.785>
creator = 'christian.heimes'
dependencies = []
files = []
hgrepos = []
issue_num = 28695
keywords = []
message_count = 7.0
messages = ['280830', '283782', '283842', '283903', '287796', '287797', '287798']
nosy_count = 4.0
nosy_names = ['christian.heimes', 'gik', 'Andrea Grandi', 'bryguy']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue28695'
versions = ['Python 3.8']

@tiran
Copy link
Member Author

tiran commented Nov 15, 2016

Python's ssl module does not support smartcard authentication of clients.
In order to use an external engine like OpenSC's engine_pkcs11, SSLContext must be configured to use a loaded engine for client cert auth. It's really simple. Pseudo code without error reporting, engine_id is a char*:

ENGINE *e = ENGINE_by_id(engine_id);
SSL_CTX_set_client_cert_engine(ctx, e);

@tiran tiran self-assigned this Nov 15, 2016
@tiran tiran added topic-SSL type-bug An unexpected behavior, bug, or error 3.7 (EOL) end of life labels Nov 15, 2016
@belolap
Copy link
Mannequin

belolap mannequin commented Dec 21, 2016

Why not to call OPENSSL_config() to use openssl.cnf?

--- ./Modules/_ssl.c.orig       2016-12-21 23:30:36.277184891 +0300
+++ ./Modules/_ssl.c    2016-12-21 23:35:18.488508435 +0300
@@ -4514,6 +4514,8 @@
     PySocketModule = *socket_api;
 
     /* Init OpenSSL */
+    OPENSSL_config(NULL);
+
     SSL_load_error_strings();
     SSL_library_init();
 #ifdef WITH_THREAD

(Patch for example, for 3.5.2 source, not try to compile)

@tiran
Copy link
Member Author

tiran commented Dec 22, 2016

OPENSSL_config() is deprecated. I'm going to wrap CONF_modules_load_file(), CONF_modules_load() and NCONF_load_bio().

@muffo
Copy link
Mannequin

muffo mannequin commented Dec 23, 2016

What about using OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL) instead of OPENSSL_config()?

@belolap
Copy link
Mannequin

belolap mannequin commented Feb 14, 2017

Is there any news?

@tiran
Copy link
Member Author

tiran commented Feb 14, 2017

I haven't started to design the new feature yet. Since it is going to be a new feature and feature freeze of 3.7 is 2018-01-29, I'm going to start working on new stuff around in April or May for PyCon.

@belolap
Copy link
Mannequin

belolap mannequin commented Feb 14, 2017

Ok, thank you.

@tiran tiran added 3.8 (EOL) end of life and removed 3.7 (EOL) end of life labels Feb 26, 2018
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@alonbl
Copy link

alonbl commented Apr 29, 2022

Hello,
Any news? it is important to be able to use private key from external devices and it fairly trivial to let openssl implement this. In future it can be extended but for now, please support it with minimal effort.
Thanks,

@kumaraditya303 kumaraditya303 added 3.12 bugs and security fixes and removed 3.8 (EOL) end of life labels Jun 9, 2022
@erlend-aasland erlend-aasland added 3.13 bugs and security fixes type-feature A feature request or enhancement and removed 3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error labels Jan 4, 2024
@krishnan793
Copy link

Any update on this? Can you share if it's possible to have a local patch to enable this?

@joenpera
Copy link

3.13.0 is out. Any update to this?

@tschenkelz
Copy link

Would also really appreciate it to get Mutual TLS handshake done using yubikey PIV

@aryeht
Copy link

aryeht commented Feb 27, 2025

mTLS handshake example with asyncio tested on the TPM device on a regular laptop available here: tpm2-software/tpm2-tools#3461

@tschenkelz
Copy link

I guess tpm is somehow different then (proper) smartcards. They are designed to prevent you from obtaining the private key that's stored on it. So there is no way to put it into a .pem file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-SSL type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

8 participants