You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2024/11/27 17:39:59 UTC
[Bug 69481] New: SSLCryptoDevice pkcs11 fails with HSM
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
Bug ID: 69481
Summary: SSLCryptoDevice pkcs11 fails with HSM
Product: Apache httpd-2
Version: 2.4.37
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: mod_ssl
Assignee: bugs@httpd.apache.org
Reporter: steve.newbold@thalestct.com
Target Milestone: ---
With Apache 2.4.37 on RHEL 8.8, configured to use SSL with private key and
certificate found on HSM partition, Thales TCT Luna T-5000. Configured with
p11kit and OpenSSL.
Client connections fail with "Error code: SSL_ERROR_INTERNAL_ERROR_ALERT"
Server is unable to support secure connection with this configuration, errors
seen when connecting to hsm.
NGINX v1.27.2 using OpenSSL/p11kit is functional, using same key/certificate
and HSM on same system.
Apache logs in messages:
Nov 27 10:55:24 101rhel systemd[1]: Started The Apache HTTP Server.
Nov 27 10:55:36 101rhel httpd[134807]: Server configured, listening on: port
443, port 80
Nov 27 10:55:47 101rhel httpd[134818]: Error message is : error:1408F119:SSL
routines:ssl3_get_record:decryption failed or bad record mac
Nov 27 10:55:47 101rhel httpd[134818]: Error message is : error:140E0197:SSL
routines:SSL_shutdown:shutdown while in init
Nov 27 10:56:15 101rhel httpd[134817]: SSL Error is (5 : 104 )
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #6 from Joe Orton <jo...@redhat.com> ---
Thanks - a few notes:
- If you use "SSLCryptoDevice pkcs11" the PKCS#11 ENGINE will be set as the
global default in OpenSSL. I think this is (almost always) undesirable if you
only really want to route key signing operations via the HSM for the configured
keypair.
- mod_ssl supports PKCS#11 URIs in SSLCertificateCertFile/KeyFile directly
since httpd 2.4.44 - this is backported into RHEL8's httpd 2.4.37, though some
later fixes/changes will not be present.
- All the errors in the systemd log are being emitted to stderr by something
other than httpd, so I guess the PKCS#11 module or ENGINE - these are not
familiar to me -
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
...
Dec 03 15:51:52 101rhel httpd[240542]: Error message is : error:1408F119:SSL
routines:ssl3_get_record:decryption >
Dec 03 15:51:52 101rhel httpd[240542]: Error message is : error:140E0197:SSL
routines:SSL_shutdown:shutdown while>
Dec 03 15:51:52 101rhel httpd[240315]: SSL Error is (5 : 104 )
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
Steve Newbold <st...@thalestct.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #3 from Steve Newbold <st...@thalestct.com> ---
(In reply to Joe Orton from comment #2)
> Thanks a lot for testing this out!
>
> 1) If you're using the RHEL httpd rather than testing upstream sources it
> would be better to report issues in RHEL Jira directly.
> https://issues.redhat.com/secure/CreateIssue!default.jspa
>
> 2) Can you try by using the PKCS#11 URI support instead directly?
>
> remove `SSLCryptoDevice pkcs11`
> add `SSLCertificateFile pkcs11:token=rhel8` assuming that URI is sufficient
> to select bot
Hi Joe,
Thank you for helping! I have a teammate with a RHEL ticket open, 03998844.
(In reply to Joe Orton from comment #2)
> Thanks a lot for testing this out!
>
> 1) If you're using the RHEL httpd rather than testing upstream sources it
> would be better to report issues in RHEL Jira directly.
> https://issues.redhat.com/secure/CreateIssue!default.jspa
>
> 2) Can you try by using the PKCS#11 URI support instead directly?
>
> remove `SSLCryptoDevice pkcs11`
> add `SSLCertificateFile pkcs11:token=rhel8` assuming that URI is sufficient
> to select bot
Thank you Joe, I really appreciate the help.
1. We have a ticket open with RHEL, 03998844, we are using the standard RHEL
yum httpd packages.
2. I tried "SSLCertificateFile pkcs11:token=rhel8",
and "SSLCertificateFile pkcs11:token=rhel8;object=POC"
and "SSLCertificateFile pkcs11:token=rhel8;object=POC;pin-value=RedHat#137"
All without the `SSLCryptoDevice pkcs11`.
I will say that I'm also getting some additional errors from the systemctl
status, jpeg attached.
We weren't aware that mod_ssl would support a pkcs11 token natively. When I
ran the first command in the list above, it prompted for the token password,
and seemed to connect.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #4 from Steve Newbold <st...@thalestct.com> ---
Created attachment 39948
--> https://bz.apache.org/bugzilla/attachment.cgi?id=39948&action=edit
Apache Mem Error with PKCS11
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #9 from Steve Newbold <st...@thalestct.com> ---
Hi Joe,
- SSLCryptoDevice pkcs11 WAS used.
- pkcs11: URIs were not added to SSLCertificateFile/SSLCertificateKeyFile
The steps used are the same as 2024-11-27 17:39:59 UTC post, with the addition
of the Apache = 1 statement in our Chrystoki.ini file.
Thank you, Steve
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #7 from Steve Newbold <st...@thalestct.com> ---
Thank you for the help. The memory errors were contained to a single instance
and not repeatable.
We have the HTTPD working well now. We have a switch enabled on the LunaClient
/etc/Chrystoki.conf configuration file with Apache = 1 in the MISC section that
allows for additional threading of Apache pkcs11 requests.
Misc = {
Apache = 1;
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #2 from Joe Orton <jo...@redhat.com> ---
Thanks a lot for testing this out!
1) If you're using the RHEL httpd rather than testing upstream sources it would
be better to report issues in RHEL Jira directly.
https://issues.redhat.com/secure/CreateIssue!default.jspa
2) Can you try by using the PKCS#11 URI support instead directly?
remove `SSLCryptoDevice pkcs11`
add `SSLCertificateFile pkcs11:token=rhel8` assuming that URI is sufficient to
select bot
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #8 from Joe Orton <jo...@redhat.com> ---
Great news, thanks for the update. It would be useful to confirm the config you
have working:
- SSLCryptoDevice pkcs11 was NOT used?
- pkcs11: URIs were used in SSLCertificateFile/SSLCertificateKeyFile
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #1 from Steve Newbold <st...@thalestct.com> ---
Instructions for p11 integration:
Prepare for the Integration
1. The PKCS #11 engine openssl-pcks11 is installed with RHEL 8, but an upgrade
will be performed.
sudo yum list installed openssl-pkcs11
Updating Subscription Management repositories.
Installed Packages
openssl-pkcs11.x86_64 0.4.8-2.el8 @anaconda
sudo yum upgrade openssl-pkcs11.x86_64
<snip>
Upgraded:
openssl-pkcs11-0.4.10-2.el8.x86_64
2. Install gnutls-utils for access to p11tool which will be used for private
key generation on the HSM. p11tool supports p11-kit
and the use of URIs, and p11-kit will be upgraded during this installation as
well.
Consult the p11tool manpage to see all the options available with this tool.
sudo yum install gnutls-utils
<snip>
Upgraded:
p11-kit-server-0.23.22-1.el8.x86_64 p11-kit-trust-0.23.22-1.el8.x86_64
p11-kit-0.23.22-1.el8.x86_64
gnutls-3.6.16-4.el8.x86_64
Installed:
gnutls-utils-3.6.16-4.el8.x86_64 autogen-libopts-5.18.12-8.el8.x86_64
gnutls-dane-3.6.16-4.el8.x86_64
3. If desired, the installed version of OpenSSL can be verified, as well as the
availability of the PKCS #11 engine. A final check
can also be made to verify the NTLS connection is available with the HSM.
openssl version
OpenSSL 1.1.1 FIPS 11 Sep 2018
openssl engine pkcs11
(pkcs11) pkcs11 engine
sudo /usr/safenet/lunaclient/bin/vtl verify
The following Slots/Partitions were found:
Slot Serial # Label
==== ================ =====
0 100093018 rhel8
Note: At any time during the ensuing integration, the lunalogs log file on the
HSM can be viewed to see/verify NTLS
activity. If Instruction is needed on how to do this, please see Appendix A.
6
Make the Luna HSM Known to p11-kit
The first step in the integration is to make the HSM known to p11-kit, which
will in turn make it available to the built-in PKCS#11 engine.
1. For informational purposes, query p11tool for the tokens currently
available. The Trust Policy Module tokens seen are
installed by default by RHEL8. They have no effect on the integration and can
be ignored. (They can also be removed using
instructions on this page.)
sudo p11tool --list-tokens
Token 0:
URL:
pkcs11:model=p11-kit-trust;manufacturer=PKCS%2311%20Kit;serial=1;token=System%20Trust
<snip>
Token 1:
URL:
pkcs11:model=p11-kit-trust;manufacturer=PKCS%2311%20Kit;serial=1;token=Default%20Trust
<snip>
2. To make the Luna HSM available to any application supporting p11-kit and the
pkcs11 engine, a configuration file needs to be
created in a specific directory (/etc/pkcs11/modules) that points to the
Cryptoki library. For this integration, the most basic
configuration file will be created, but more information on the possible
contents of this file can be found here.
The file created must have the .module extension, but can be otherwise named
anything. Here, a file named luna.module
will be created with the simple file contents shown below.
sudo vi /etc/pkcs11/modules/luna.module
File contents:
# path to .so
module: /usr/safenet/lunaclient/lib/libCryptoki2_64.so
Note: Do not put any extraneous files in the /etc/pkcs11/modules directory.
3. By virtue of just creating that file, the Luna HSM should now be seen in the
token list. The --list-token-urls command will
provide a more compact list showing the available tokens. All that is needed to
uniquely address a token in future steps is the
token=xxxxxx part of the URI, which identifies the partition, but the full URI
see below could be used. If an HA Group is
established, the HA Group name should be used instead of the partition name.
.
sudo p11tool --list-token-urls
pkcs11:model=p11-kit-trust;manufacturer=PKCS%2311%20Kit;serial=1;token=System%20Trust
pkcs11:model=p11-kit-trust;manufacturer=PKCS%2311%20Kit;serial=1;token=Default%20Trust
pkcs11:model=LunaSA%207.12.0;manufacturer=Thales%20TCT;serial=100093018;token=rhel8
4. To verify basic connectivity with the HSM using p11-kit, the following
command could be issued which will list all the public
objects on the partition. Note that no partition password is required for this
action, and No matching objects found will be
seen if the partition is empty.
sudo p11tool --list-all "pkcs11:token=rhel8"
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69481] SSLCryptoDevice pkcs11 fails with HSM
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69481
--- Comment #5 from Steve Newbold <st...@thalestct.com> ---
Additional information:
Dec 03 15:46:40 101rhel systemd[1]: Starting The Apache HTTP Server...
Dec 03 15:46:53 101rhel httpd[240295]: AH00558: httpd: Could not reliably
determine the server's fully qualified >
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel httpd[240295]: error is c0000001, RC_MEMORY_ALLOCATION
Dec 03 15:46:53 101rhel systemd[1]: Started The Apache HTTP Server.
Dec 03 15:47:05 101rhel httpd[240295]: Server configured, listening on: port
443, port 80
Dec 03 15:51:52 101rhel httpd[240542]: Error message is : error:1408F119:SSL
routines:ssl3_get_record:decryption >
Dec 03 15:51:52 101rhel httpd[240542]: Error message is : error:140E0197:SSL
routines:SSL_shutdown:shutdown while>
Dec 03 15:51:52 101rhel httpd[240315]: SSL Error is (5 : 104 )
[root@101rhel conf.d]# service httpd restart
Redirecting to /bin/systemctl restart httpd.service
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org