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

TLS With Certificate Management for PVXS #92

Draft
wants to merge 192 commits into
base: tls
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
ffdb943
Update README.md
george-mcintyre Feb 17, 2023
4643c8d
Add long long tests
george-mcintyre May 29, 2023
6e381de
update bundled libevent
mdavidsaver Jul 19, 2023
0591b99
conditionally link with libssl
mdavidsaver Jul 4, 2023
30307ea
consolidate config common to both server and client
mdavidsaver Jun 12, 2023
e149caa
Add TLS support w/ OpenSSL
mdavidsaver Nov 7, 2023
707e6b1
py build w/ openssl
mdavidsaver Aug 12, 2023
691151b
Merge branch 'mdavidsaver:master' into master
george-mcintyre May 11, 2024
895177f
Merge branch 'tls' of github.com:mdavidsaver/pvxs into tls
george-mcintyre Jun 30, 2024
1025323
Implement Certificate Management and Site Authentication
george-mcintyre Jul 1, 2024
f46acb0
Add guards for TLS implementation.
george-mcintyre Jul 6, 2024
1d55ba4
Add guards for TLS implementation.
george-mcintyre Jul 6, 2024
edaeb7a
Code moved around/separated and regular tls stuff working but new stu…
george-mcintyre Jul 7, 2024
88673aa
Code moved around/separated and regular tls stuff working but new stu…
george-mcintyre Jul 7, 2024
dd42393
Code moved around/separated and regular tls stuff working but new stu…
george-mcintyre Jul 7, 2024
0081f00
PVACMS working. Ready for registration of authn methods
george-mcintyre Jul 8, 2024
8de2411
Add custom `validUntilRevoked` extension to all certificates
george-mcintyre Jul 16, 2024
4e7ba80
Add custom `validUntilRevoked` extension to all certificates
george-mcintyre Jul 19, 2024
6732515
Add certid and cert status and revoke pvs to cert create response
george-mcintyre Jul 19, 2024
1dc2204
Store skid in database when creating certificates
george-mcintyre Jul 19, 2024
387087b
Check for duplicate certificates
george-mcintyre Jul 19, 2024
90d47a0
Update cert management to use correct pvs for CMS
george-mcintyre Jul 21, 2024
06f5550
Add cert rotate
george-mcintyre Jul 27, 2024
d0efd09
proper impl but still need to tell functions to call back again even …
george-mcintyre Jul 29, 2024
d59bcff
ok done with wildcard stuff
george-mcintyre Jul 29, 2024
f43ddae
ok done with wildcard stuff
george-mcintyre Jul 29, 2024
9007c9d
closer to monitor
george-mcintyre Jul 29, 2024
df0a8bf
monitor done
george-mcintyre Jul 29, 2024
f12661c
ocsp status
george-mcintyre Jul 31, 2024
bf17744
ocsp status
george-mcintyre Aug 5, 2024
ab59be2
Monitoring and monitoring threead
george-mcintyre Aug 6, 2024
3e0cc05
marked monitors
george-mcintyre Aug 7, 2024
7c663ae
Separate out private key into separate file (or read operation)
george-mcintyre Aug 8, 2024
049ab54
Lots of cosmetics and a big bug
george-mcintyre Aug 9, 2024
d31a60f
rename keychain to cert and private key and class to P12FileFactory
george-mcintyre Aug 10, 2024
f7ac1f2
cosmetic
george-mcintyre Aug 10, 2024
3a99d50
Add new fields to cert status and decode ocsp response
george-mcintyre Aug 11, 2024
25158ef
Add version that can return time_t for status
george-mcintyre Aug 11, 2024
0413feb
Return status correctly
george-mcintyre Aug 12, 2024
2a36418
Rationalise names of ocsp members in cert status
george-mcintyre Aug 12, 2024
5918465
Rationalise names of ocsp members in cert status
george-mcintyre Aug 12, 2024
4c892f4
Rationalise names of ocsp members in cert status
george-mcintyre Aug 12, 2024
5cce290
undo attempt to force mark fields that have changed
george-mcintyre Aug 13, 2024
4b5fbde
templatize parsing of ocsp response and allow parsing of responses co…
george-mcintyre Aug 14, 2024
d690461
Rename CertificateStatus to CertStatus
george-mcintyre Aug 14, 2024
6f8b28b
Refactor posting status and generating oscp responses so that a commo…
george-mcintyre Aug 14, 2024
39cdbb5
Refactor ocsp helper
george-mcintyre Aug 15, 2024
b37803f
Formatting
george-mcintyre Aug 15, 2024
4fe76fb
Add chain to verification
george-mcintyre Aug 15, 2024
3a0c801
Add custom extension to certs if CMS flag set
george-mcintyre Aug 20, 2024
040c580
Move manager code to PVXS and keep factory in PVACMS
george-mcintyre Aug 21, 2024
b1245dd
Share code to register NIDs between CMS and pvxs lib
george-mcintyre Aug 21, 2024
6d5f9f6
Update ccr.sh to be able to create client certs in a password protect…
george-mcintyre Aug 22, 2024
e46622b
Update ccr.sh to be able to create client certs in a password protect…
george-mcintyre Aug 22, 2024
82df70f
add enum for ocspcertstatus_t auto generating names and change refere…
george-mcintyre Aug 24, 2024
ab2e4e5
filewatcher v1
george-mcintyre Aug 25, 2024
b575945
get cert status
george-mcintyre Aug 25, 2024
86527e5
remove extraneous certstatusclient
george-mcintyre Aug 25, 2024
e440969
move lambdas into subscribe and watch methods
george-mcintyre Aug 25, 2024
6dcde09
Finished coding for Status listener and file watcher but don't know h…
george-mcintyre Aug 26, 2024
72fa867
Install file watcher - in (missing two calls to reconfigure though)
george-mcintyre Aug 26, 2024
f13cb44
Starting to install status listener
george-mcintyre Aug 26, 2024
2ff49cc
Update ccr script to make valid certs that need approval
george-mcintyre Aug 28, 2024
924f5e0
Refactor watchers and context reconfiguration system
george-mcintyre Aug 29, 2024
9218793
Refactor watchers and context reconfiguration system
george-mcintyre Aug 29, 2024
3ae9e28
More updates
george-mcintyre Aug 29, 2024
7552a2e
More updates
george-mcintyre Aug 29, 2024
ebfe6e4
More updates
george-mcintyre Aug 29, 2024
c236a88
More updates
george-mcintyre Aug 29, 2024
0ccb93e
More updates
george-mcintyre Aug 30, 2024
069cf82
More updates
george-mcintyre Sep 1, 2024
c13fe4e
Tests for tlstime
george-mcintyre Sep 3, 2024
a994827
Tests for tlsstatus part 1
george-mcintyre Sep 4, 2024
3691309
Tests for tlsstatus part 1
george-mcintyre Sep 5, 2024
043bf5b
Converted Status Monitor to libevent
george-mcintyre Sep 6, 2024
b12c69a
Converted Status Monitor to libevent
george-mcintyre Sep 6, 2024
9aab2a6
Converted Status Monitor to libevent
george-mcintyre Sep 6, 2024
70a4189
Converted Status Monitor to libevent
george-mcintyre Sep 6, 2024
524d639
Converted Status Monitor to libevent
george-mcintyre Sep 7, 2024
c2f2842
Refactor File watcher and status watcher into libevent
george-mcintyre Sep 9, 2024
9c26f8a
Refactor File watcher and status watcher into libevent
george-mcintyre Sep 9, 2024
84e8048
Refactor File watcher and status watcher into libevent
george-mcintyre Sep 9, 2024
a177dd4
Refactor File watcher and status watcher into libevent
george-mcintyre Sep 9, 2024
215360d
Refactor File watcher and status watcher into libevent
george-mcintyre Sep 9, 2024
b92d5e3
Refactor File watcher and status watcher into libevent
george-mcintyre Sep 9, 2024
addbe59
Finalized client side reconfiguration
george-mcintyre Sep 9, 2024
dfbae63
Finalized client side reconfiguration
george-mcintyre Sep 9, 2024
99231e5
Renames
george-mcintyre Sep 9, 2024
bf71185
JWT Tester and impl of authnjwt
george-mcintyre Sep 10, 2024
09bb840
Change cert_invalid to cert_valid
george-mcintyre Sep 12, 2024
fcb45ad
Add pvxcert command
george-mcintyre Sep 13, 2024
ccc9b5e
Add pvxcert command
george-mcintyre Sep 13, 2024
148214b
Wait for pending status if required
george-mcintyre Sep 14, 2024
4e46b62
stapling and status monitoring
george-mcintyre Sep 18, 2024
e86e98d
stapling and status monitoring
george-mcintyre Sep 18, 2024
641269e
stapling and status monitoring
george-mcintyre Sep 18, 2024
dcec1b3
stapling and status monitoring
george-mcintyre Sep 19, 2024
7edca4d
authnstd
george-mcintyre Sep 19, 2024
406f29e
authnstd
george-mcintyre Sep 19, 2024
95e8383
TODOs
george-mcintyre Sep 19, 2024
2cdd672
copy instead of reference bug
george-mcintyre Sep 19, 2024
d11921b
Enable client stapling support
george-mcintyre Sep 19, 2024
5e1f56c
Enable client stapling support
george-mcintyre Sep 19, 2024
c76679d
Enable client stapling support
george-mcintyre Sep 19, 2024
f10048d
Enable client stapling support
george-mcintyre Sep 19, 2024
45be963
Better ccr
george-mcintyre Sep 21, 2024
2ba88c1
Add OCSP callback and implement certificate status management improve…
george-mcintyre Sep 24, 2024
39c1925
Refactor TLS status handling and logging improvements
george-mcintyre Sep 27, 2024
73bf10b
Refactor TLS status handling and logging improvements
george-mcintyre Sep 27, 2024
7d1e969
Add `CertifiedCertificateStatus` struct and simplify test code
george-mcintyre Sep 28, 2024
0163d4f
Refactor status posting logic and add CertifiedCertificateStatus chec…
george-mcintyre Sep 28, 2024
00db4b5
Refactored code to replace `CertificateStatus` with `PVACertificateSt…
george-mcintyre Sep 29, 2024
3b53593
Refactor CertificateStatus handling and rename UncertifiedCertificate…
george-mcintyre Sep 29, 2024
e5cd51c
Improve Certificate Status Comparison and Enhance Test Naming
george-mcintyre Sep 30, 2024
bb9dfc2
Add operator overloads for certificate status comparisons
george-mcintyre Sep 30, 2024
b98d483
Formatting and more status operators
george-mcintyre Sep 30, 2024
50054c6
Formatting and more status operators
george-mcintyre Sep 30, 2024
8e257de
Refactor Certificate Status Handling
george-mcintyre Oct 1, 2024
2ac5c61
- Refactored `postCertificateStatus` to use `cloneEmpty` method for s…
george-mcintyre Oct 1, 2024
c4a16df
Add test for TLS with CMS setup and related utilities
george-mcintyre Oct 6, 2024
30558f2
Add optional TLS stapling disable toggle and improve logging
george-mcintyre Oct 7, 2024
7f2a4f9
Add conditional OpenSSL checks and stop functionality for file watche…
george-mcintyre Oct 7, 2024
e80a6d3
Add 'running' state management to P12FileWatcher class
george-mcintyre Oct 7, 2024
ab6ad6a
Add new TLS tests with stapling and CMS
george-mcintyre Oct 7, 2024
f507dd9
Remove testtlswithstapling and improve OCSP stapling debug messages.
george-mcintyre Oct 7, 2024
c5837e9
Refactor TLS and OCSP Handling for Clients and Servers
george-mcintyre Oct 8, 2024
8c03d31
Add early return in serverOCSPCallback for non-stapling requests
george-mcintyre Oct 8, 2024
2d9c639
Refactor TLS and OCSP handling for clarity and consistency
george-mcintyre Oct 8, 2024
6d1f462
Update IOC certificate from IOC to IOC1 and add detailed documentatio…
george-mcintyre Oct 9, 2024
fac7de4
Update testPlan count from 136 to 142 in testtlswithcmsandstapling.cpp
george-mcintyre Oct 9, 2024
abc590e
Add detailed documentation for certificate testing code
george-mcintyre Oct 10, 2024
c73c9db
Refactor CMS status requests and enhance SSL context handling
george-mcintyre Oct 12, 2024
f417ca0
Refactor and enhance certificate status management
george-mcintyre Oct 12, 2024
89fb186
Add certificate verification callback with peer status monitoring (cl…
george-mcintyre Oct 12, 2024
26d6e0c
Add Windows support and improve SSL peer status management
george-mcintyre Oct 13, 2024
8201b0e
Update .gitignore to include additional IDE, build, and test files
george-mcintyre Oct 13, 2024
f257a53
Add tests for TLS backwards compatibility in client and server config…
george-mcintyre Oct 13, 2024
9205ce5
Refactor certificate status handling in tests
george-mcintyre Oct 13, 2024
cbe145b
Refactored test case variables and added reset and validation macros …
george-mcintyre Oct 14, 2024
147a156
Refactor Certificate Status Management and Add Enhanced Tests
george-mcintyre Oct 14, 2024
9617ed7
Add CA certificate status handling and logging improvements
george-mcintyre Oct 15, 2024
5982a57
"Refactor TLS configuration: standardize status check and stapling se…
george-mcintyre Oct 15, 2024
f043c57
Format code and fix minor formatting issues in test files and CertSta…
george-mcintyre Oct 15, 2024
9316952
Add null check in ServerSource::onCreate and initialize is_initialize…
george-mcintyre Oct 15, 2024
7b9dc94
Remove timeout mechanism in PVAccess connections
george-mcintyre Oct 15, 2024
3453c78
Refactor certificate status subscription, introduce enhanced error ha…
george-mcintyre Oct 29, 2024
c13b829
Refactor certificate status management and add P12 key/cert utilities
george-mcintyre Oct 29, 2024
26f91a2
Remove redundant functions, move function definition, and rename loggers
george-mcintyre Oct 29, 2024
bf61722
Add support for additional TLS options
george-mcintyre Oct 29, 2024
d2447c4
Remove conditional OpenSSL code and simplify connection dispatch logic
george-mcintyre Oct 30, 2024
5037799
Refactor and streamline security client code and credentials handling
george-mcintyre Nov 9, 2024
d8acc59
Enhanced comments and documentation for CMS configuration and wildcar…
george-mcintyre Nov 11, 2024
cd980bb
Add secure PVAccess (SPVA) documentation and refactor certificate han…
george-mcintyre Nov 25, 2024
6ff237d
"Fix section numbering in securepva.rst documentation."
george-mcintyre Nov 25, 2024
221c55d
Update securepva documentation: add steps to fetch and build PVXS wit…
george-mcintyre Nov 25, 2024
bc23d04
Update environment variable names in securepva documentation for cons…
george-mcintyre Nov 25, 2024
8fcf6d9
Update securepva.rst and remove _log_println function
george-mcintyre Nov 25, 2024
a7937c8
Update securepva.rst documentation to clone PVXS from a specific branch.
george-mcintyre Nov 25, 2024
effd0fe
Remove superfluous sqlite header
george-mcintyre Nov 25, 2024
638486b
More portable curl library reference
george-mcintyre Nov 25, 2024
61704d8
More portable sqlite library reference
george-mcintyre Nov 25, 2024
9fe1778
Default to vanilla build
george-mcintyre Nov 25, 2024
f38dd14
cosmetic doc change
george-mcintyre Nov 25, 2024
15472b3
Update root certificate handling and improve documentation
george-mcintyre Dec 1, 2024
f527c07
Add PEMFileFactory and Enhance Certificate Handling
george-mcintyre Dec 3, 2024
46351c4
Refactor certificate file handling for enhanced modularity and extens…
george-mcintyre Dec 3, 2024
8e21e0d
Refactor Certificate Factories to Support Password and KeyPair
george-mcintyre Dec 3, 2024
3720e03
Add documentation for supported certificate formats and usage.
george-mcintyre Dec 3, 2024
25f3517
Update file extensions in pemfilefactory and fix typo in documentation
george-mcintyre Dec 3, 2024
a0e586a
Add 'false' parameter to ossl_ptr instances for proper initialization…
george-mcintyre Dec 3, 2024
a414296
Ensure file pointers in certificate-related utilities are constructed…
george-mcintyre Dec 3, 2024
6ee52eb
Add error handling to certfilefactory and better
george-mcintyre Dec 5, 2024
27a54d8
Refactor certificate management: integrate CLI11 library and enhance …
george-mcintyre Dec 6, 2024
dc9865b
Refactor cert.cpp: re-order includes, improve formatting, and add CLI…
george-mcintyre Dec 6, 2024
192dc67
Add support for TLS certificate and key management
george-mcintyre Dec 6, 2024
feb021c
Update command-line usage instructions in securepva.rst
george-mcintyre Dec 6, 2024
c1f3e5d
Refactor to use custom smart pointer type for CertFileFactory
george-mcintyre Dec 8, 2024
f973f98
Improve error message for unsupported certificate file extension by d…
george-mcintyre Dec 8, 2024
69a0b07
Remove obsolete instructions for setting library paths in securepva d…
george-mcintyre Dec 8, 2024
b7fb0d4
Refactor code formatting for improved readability
george-mcintyre Dec 8, 2024
bda7def
Refactor cert file handling to use `writeIdentityFile` method
george-mcintyre Dec 8, 2024
1f3a7f2
Rename `CertFileFactory` to `IdFileFactory` across multiple files for…
george-mcintyre Dec 8, 2024
a05203b
Implement OCSP response verification and certificate trust check enha…
george-mcintyre Dec 8, 2024
5b3bce1
Improve logging and output formatting for certificate installation
george-mcintyre Dec 8, 2024
332e65a
Clarify error message for duplicate Certificate Subject Key Identifie…
george-mcintyre Dec 8, 2024
488071c
Refactor PVACS Configuration and Setup for Improved Clarity and Funct…
george-mcintyre Dec 8, 2024
8805d9d
Refactor and clean up certificate management code
george-mcintyre Dec 9, 2024
7127067
Refactor configstd.cpp: Remove redundant variables and update pvacms …
george-mcintyre Dec 9, 2024
d5e1737
Refactored code to support authentication configuration enhancements:
george-mcintyre Dec 9, 2024
95100c3
Improve key retrieval and error messages; update documentation.
george-mcintyre Dec 9, 2024
945b370
Refactor ACF generation: simplify code and remove unused issuer ID. A…
george-mcintyre Dec 9, 2024
698ebb5
Refactor `SecurityClient::update` method to support `ASMEMBERPVT` and…
george-mcintyre Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci-scripts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ jobs:
- name: "apt-get install"
run: |
sudo apt-get update
sudo apt-get -y install g++-mingw-w64-x86-64 cmake gdb qemu-system-x86
sudo apt-get -y install g++-mingw-w64-x86-64 cmake gdb qemu-system-x86 libssl-dev
if: runner.os == 'Linux'
- name: Host Info
run: openssl version -a
- name: Automatic core dumper analysis
uses: mdavidsaver/ci-core-dumper@master
- name: Prepare and compile dependencies
Expand Down
47 changes: 46 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,49 @@ __pycache__/
*.orig
*.log
.*.swp
.vscode
.vscode
.clang-format
.iocsh_history
EPICS_CA.pem
login_certs.txt
system_certs.txt
.idea/editor.xml
.idea/misc.xml
.idea/modules.xml
.idea/pvxs.iml
.idea/vcs.xml
.idea/workspace.xml
.idea/codeStyles/codeStyleConfig.xml
.idea/copyright/profiles_settings.xml
.idea/inspectionProfiles/Project_Default.xml
.idea/shelf/Add_detailed_documentation_for_certificate_testing_code__Enhanced_the__testtlswithcmsandst.xml
.idea/shelf/authenticator_framework.xml
.idea/shelf/big_refactor.xml
.idea/shelf/Changes.xml
.idea/shelf/Don_t_kn.xml
.idea/shelf/framework_updates.xml
.idea/shelf/Kerberos_spike.xml
.idea/shelf/move_lambdas_into_subscribe_and_watch_methods.xml
.idea/shelf/rename_CertificateStatus_and_change_OCSPStatus_creation_and_verification.xml
.idea/shelf/statuslistener.xml
.idea/shelf/subdirectories_for_each_auth_method1.xml
.idea/shelf/Add_detailed_documentation_for_certificate_testing_code__Enhanced_the_`testtlswithcmsandst/shelved.patch
.idea/shelf/authenticator_framework/shelved.patch
.idea/shelf/big_refactor/shelved.patch
.idea/shelf/Changes/shelved.patch
.idea/shelf/Don't_kn/shelved.patch
.idea/shelf/framework_updates/shelved.patch
.idea/shelf/Kerberos_spike/shelved.patch
.idea/shelf/move_lambdas_into_subscribe_and_watch_methods/shelved.patch
.idea/shelf/rename_CertificateStatus_and_change_OCSPStatus_creation_and_verification/shelved.patch
.idea/shelf/statuslistener/shelved.patch
.idea/shelf/subdirectories_for_each_auth_method1/shelved.patch
configure/TOOLCHAIN.tmp
test/testioc.db
test/testiocg.db
test/slac-test/Sign In.htm
test/slac-test/Sign In.mhtml
test/slac-test/Sign In_files/doe-logo.png
test/slac-test/Sign In_files/logo.png
test/slac-test/Sign In_files/stanford-logo.png
test/slac-test/Sign In_files/style.css
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "bundle/libevent"]
path = bundle/libevent
url = https://github.com/libevent/libevent
[submodule "bundle/jwt-cpp"]
path = bundle/jwt-cpp
url = https://github.com/Thalhammer/jwt-cpp.git
[submodule "bundle/CLI11"]
path = bundle/CLI11
url = https://github.com/CLIUtils/CLI11.git
28 changes: 28 additions & 0 deletions .idea/jsonSchemas.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include LICENSE
include README.md

include configure/CONFIG_PVXS_VERSION
include configure/probe-openssl.c
include src/*.h
include src/*.h@
include src/*.cpp
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ include $(TOP)/configure/CONFIG
# Directories to build, any order
DIRS += configure

DIRS += setup
setup_DEPEND_DIRS = configure

DIRS += src
src_DEPEND_DIRS = configure
src_DEPEND_DIRS = setup

DIRS += tools
tools_DEPEND_DIRS = src
Expand All @@ -22,6 +25,9 @@ endif
DIRS += test
test_DEPEND_DIRS = src ioc

DIRS += certs
certs_DEPEND_DIRS = src

DIRS += example
example_DEPEND_DIRS = src

Expand Down
1 change: 1 addition & 0 deletions bundle/CLI11
Submodule CLI11 added at 063b2c
3 changes: 2 additions & 1 deletion bundle/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
TOP=..

_PVXS_BOOTSTRAP = YES

include $(TOP)/configure/CONFIG

CMAKE ?= cmake
Expand All @@ -21,7 +23,6 @@ LIBEVENT_$(T_A) = $(INSTALL_LOCATION)/bundle/usr/$(T_A)
CMAKEFLAGS += -DCMAKE_INSTALL_PREFIX:PATH="$(abspath $(LIBEVENT_$(T_A)))"

# not needed, and may not be available on embedded targets, so never try
CMAKEFLAGS += -DEVENT__DISABLE_OPENSSL=ON
CMAKEFLAGS += -DEVENT__DISABLE_MBEDTLS=ON

# not run, so why bother?
Expand Down
1 change: 1 addition & 0 deletions bundle/jwt-cpp
Submodule jwt-cpp added at a6927c
2 changes: 1 addition & 1 deletion bundle/libevent
Submodule libevent updated 111 files
55 changes: 55 additions & 0 deletions certs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
TOP=..

include $(TOP)/configure/CONFIG
# cfg/ sometimes isn't correctly included due to a Base bug
# so we do here (maybe again) as workaround
-include $(wildcard $(TOP)/cfg/CONFIG*)
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================

ifeq ($(EVENT2_HAS_OPENSSL),YES)
USR_CPPFLAGS += -DPVXS_ENABLE_OPENSSL -I$(TOP)/bundle/CLI11/include
AUTHN = $(TOP)/certs/authn
SRC_DIRS += $(TOP)/src
SRC_DIRS += $(TOP)/ioc
SRCS += p12filefactory.cpp
SRCS += pemfilefactory.cpp
SRCS += certfilefactory.cpp
SRCS += certfactory.cpp

PROD_LIBS = pvxs Com

# access to API and private headers
USR_CPPFLAGS += -I$(TOP)/src/pvxs
USR_CPPFLAGS += -I$(TOP)/src
USR_CPPFLAGS += -I$(TOP)/ioc

#INC += certstatus.h
INC += security.h

PROD += pvacms
pvacms_SRCS += pvacms.cpp
pvacms_SRCS += configcms.cpp
pvacms_SRCS += certstatus.cpp
pvacms_SRCS += certstatusfactory.cpp
pvacms_SRCS += credentials.cpp
pvacms_SRCS += securityclient.cpp

pvacms_LIBS += $(EPICS_BASE_IOC_LIBS)
pvacms_SYS_LIBS += sqlite3 ssl crypto

#PROD += ocsppva
#pvaocsp_SRCS += ocsppva.cpp
#pvaocsp_SRCS += configocsp.cpp

include $(AUTHN)/Makefile

endif # EVENT2_HAS_OPENSSL

#===========================

include $(TOP)/configure/RULES
-include $(wildcard $(TOP)/cfg/RULES*)
#----------------------------------------
# ADD RULES AFTER THIS LINE
23 changes: 23 additions & 0 deletions certs/authn/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This is a Makefile fragment, see cert/Makefile.

SRC_DIRS += $(AUTHN)

#--------------------------------------------
# ADD AUTHENTICATION PLUGINS AFTER THIS LINE

SRCS += auth.cpp
SRCS += ccrmanager.cpp

include $(AUTHN)/std/Makefile

ifeq ($(PVXS_ENABLE_JWT_AUTH),YES)
include $(AUTHN)/jwt/Makefile
endif

ifeq ($(PVXS_ENABLE_KRB_AUTH),YES)
include $(AUTHN)/krb/Makefile
endif

ifeq ($(PVXS_ENABLE_LDAP_AUTH),YES)
include $(AUTHN)/ldap/Makefile
endif
93 changes: 93 additions & 0 deletions certs/authn/auth.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* pvxs is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/

#include "auth.h"

#include <iostream>
#include <memory>
#include <string>

#include <pvxs/log.h>

#include "ccrmanager.h"
#include "certfactory.h"
#include "ownedptr.h"
#include "p12filefactory.h"
#include "security.h"

namespace pvxs {
namespace certs {

/**
* @brief Creates a signed certificate.
*
* Create a PVStructure that corresponds to the ccr parameter of a certificate
* creation request. This request will be sent to the PVACMS through the default
* channel (PVAccess) and will be used to create the certificate.
*
* @param credentials the credentials that describe the subject of the
* certificate
* @param key_pair the public/private key to be used in the certificate, only
* public key is used
* @param usage the desired certificate usage
* @return A managed shared CertCreationRequest object.
*/
std::shared_ptr<CertCreationRequest> Auth::createCertCreationRequest(const std::shared_ptr<Credentials> &credentials, const std::shared_ptr<KeyPair> &key_pair,
const uint16_t &usage) const {
// Create a new CertCreationRequest object.
auto cert_creation_request = std::make_shared<CertCreationRequest>(type_, verifier_fields_);
cert_creation_request->credentials = credentials;

// Fill in the ccr from the base data we've gathered so far.
cert_creation_request->ccr["name"] = credentials->name;
cert_creation_request->ccr["country"] = credentials->country;
cert_creation_request->ccr["organization"] = credentials->organization;
cert_creation_request->ccr["organization_unit"] = credentials->organization_unit;
cert_creation_request->ccr["type"] = type_;
cert_creation_request->ccr["usage"] = usage;
cert_creation_request->ccr["not_before"] = credentials->not_before;
cert_creation_request->ccr["not_after"] = credentials->not_after;
cert_creation_request->ccr["pub_key"] = key_pair->public_key;
return cert_creation_request;
}

/**
* @brief Signs a certificate.
*
* This function takes a certificate creation request and sends its ccr
* PVStructure to PVACMS to be signed. It will wait for the signed signature or
* any reported error.
*
* @param cert_creation_request A shared pointer to a CertCreationRequest object
* containing the ccr PVStructure which contains the certificate, and its
* validity as well as any verifier specific required fields.
* @return the signed certificate
* @throws std::runtime_error when exceptions arise
*
* @note It is the responsibility of the caller to ensure that the
* cert_creation_request object is valid and contains the required information
* before calling this function.
*/
std::string Auth::processCertificateCreationRequest(const std::shared_ptr<CertCreationRequest> &cert_creation_request) const {
// Forward the ccr to the certificate management service
std::string p12_pem_string(ccr_manager_.createCertificate(cert_creation_request));
return p12_pem_string;
}

std::shared_ptr<KeyPair> Auth::createKeyPair(const ConfigCommon &config) {
// Create a key pair
const auto key_pair(IdFileFactory::createKeyPair());

// Create private key file containing private key
if ( config.tls_private_key_filename.empty()) {
IdFileFactory::create(config.tls_cert_filename, config.tls_cert_password, key_pair)->writeIdentityFile();
} else {
IdFileFactory::create(config.tls_private_key_filename, config.tls_private_key_password, key_pair)->writeIdentityFile();
}
return key_pair;
}
} // namespace certs
} // namespace pvxs
Loading
Loading