Skip to content

Commit f93def1

Browse files
sfayerweb-flow
authored andcommitted
sweep: DIRACGrid#8091 Don't use string processing on X509 name objects
1 parent 49b527f commit f93def1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/DIRAC/Core/Security/m2crypto/X509Certificate.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,11 @@ def generateProxyCertFromIssuer(cls, x509Issuer, x509ExtensionStack, proxyKey, l
9999
proxySubject = M2Crypto.X509.X509_Name()
100100

101101
issuerSubjectObj = x509Issuer.__certObj.get_subject()
102-
# pylint: disable=no-member
103-
issuerSubjectParts = issuerSubjectObj.as_text(flags=M2Crypto.m2.XN_FLAG_RFC2253).split(",")
104102

105-
# XN_FLAG_RFC2253 prints in reverse order but DIRAC has historically used the standard order
106-
for isPart in issuerSubjectParts[::-1]:
107-
nid, val = isPart.split("=", 1)
108-
proxySubject.add_entry_by_txt(field=nid, type=M2Crypto.ASN1.MBSTRING_ASC, entry=val, len=-1, loc=-1, set=0)
103+
# Copy the X509 entry components into the new name
104+
for entry in issuerSubjectObj:
105+
# pylint: disable=no-member
106+
M2Crypto.m2.x509_name_add_entry(proxySubject.x509_name, entry.x509_name_entry, -1, 0)
109107

110108
# Finally we add a random Common Name component. And we might as well use the serial.. :)
111109
proxySubject.add_entry_by_txt(

0 commit comments

Comments
 (0)