Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
cddf43c7
Commit
cddf43c7
authored
Oct 31, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_certificate_authority: Calculate only once they private_key for templates
parent
a6c5a2ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
bt5/erp5_certificate_authority/DocumentTemplateItem/portal_components/document.erp5.CaucaseConnector.py
...eItem/portal_components/document.erp5.CaucaseConnector.py
+14
-5
No files found.
bt5/erp5_certificate_authority/DocumentTemplateItem/portal_components/document.erp5.CaucaseConnector.py
View file @
cddf43c7
...
...
@@ -43,9 +43,13 @@ from cryptography.hazmat.primitives.asymmetric import rsa
from
cryptography.x509.oid
import
NameOID
import
tempfile
_DEFAULTBACKEND
=
default_backend
()
class
CaucaseConnector
(
XMLObject
):
meta_type
=
'Caucase Connector'
__private_template_key
=
None
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
...
...
@@ -76,9 +80,14 @@ class CaucaseConnector(XMLObject):
user_key_file
.
flush
()
return
self
.
_getServiceConnection
(
user_key
=
user_key_file
.
name
)
def
__getPrivateTemplateKey
(
self
):
if
not
self
.
__private_template_key
:
self
.
__private_template_key
=
rsa
.
generate_private_key
(
public_exponent
=
65537
,
key_size
=
2048
,
backend
=
_DEFAULTBACKEND
)
return
self
.
__private_template_key
def
getCertificateSigningRequestTemplate
(
self
,
common_name
):
key
=
rsa
.
generate_private_key
(
public_exponent
=
65537
,
key_size
=
2048
,
backend
=
default_backend
())
key
=
self
.
__getPrivateTemplateKey
()
name_attribute_list
=
self
.
_getSubjectNameAttributeList
()
name_attribute_list
.
append
(
...
...
@@ -88,7 +97,7 @@ class CaucaseConnector(XMLObject):
csr
=
x509
.
CertificateSigningRequestBuilder
().
subject_name
(
x509
.
Name
(
name_attribute_list
)).
sign
(
key
,
hashes
.
SHA256
(),
default_backend
()
)
)).
sign
(
key
,
hashes
.
SHA256
(),
_DEFAULTBACKEND
)
return
csr
.
public_bytes
(
serialization
.
Encoding
.
PEM
).
decode
()
...
...
@@ -146,7 +155,7 @@ class CaucaseConnector(XMLObject):
def
_createCertificateRequest
(
self
):
key
=
rsa
.
generate_private_key
(
public_exponent
=
65537
,
key_size
=
2048
,
backend
=
default_backend
()
)
public_exponent
=
65537
,
key_size
=
2048
,
backend
=
_DEFAULTBACKEND
)
key_pem
=
key
.
private_bytes
(
encoding
=
serialization
.
Encoding
.
PEM
,
format
=
serialization
.
PrivateFormat
.
PKCS8
,
...
...
@@ -162,7 +171,7 @@ class CaucaseConnector(XMLObject):
# Probably we should extend a bit more the attributes.
csr
=
x509
.
CertificateSigningRequestBuilder
().
subject_name
(
x509
.
Name
(
name_attribute_list
)).
sign
(
key
,
hashes
.
SHA256
(),
default_backend
()
)
)).
sign
(
key
,
hashes
.
SHA256
(),
_DEFAULTBACKEND
)
return
key_pem
.
decode
(),
csr
.
public_bytes
(
serialization
.
Encoding
.
PEM
).
decode
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment