-
Notifications
You must be signed in to change notification settings - Fork 48
Changes for MLE Request for HTTP Signature #171
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
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
if (this.mleForRequestPublicCertPath !== null && this.mleForRequestPublicCertPath !== undefined) { | ||
var certFile = path.resolve(path.join(this.mleForRequestPublicCertPath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing a path.join()
on a single string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
src/authentication/util/Cache.js
Outdated
} catch (err) { | ||
logger.warn("MLE certificate file not found or not readable: " + mleCertPath); | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be doing line 93 - 99 in MerchantConfig.js
and store the validated path in a variable inside merchantConfig object.
There is no reason why all the steps up to this point should be done, just for it to fail here because of missing/incorrect paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you are repeating this logic to check if the file exists or not again and again. Refer line 22 & 23.
src/authentication/util/Cache.js
Outdated
mleCert = loadCertificateFromPem(merchantConfig, mleCertPath); | ||
} | ||
else if (cacheKey.endsWith(Constants.MLE_CACHE_IDENTIFIER_FOR_P12_CERT)) { | ||
mleCert = loadCertificateFromP12(merchantConfig, mleCertPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is wrong here. This is the case for taking the MLE certificate out of the P12 file. Why are you passing mleCertPath
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here mleCertPath
will be storing the P12 cert path.
var p12Der = forge.util.binary.raw.encode(new Uint8Array(p12Buffer)); | ||
var p12Asn1 = forge.asn1.fromDer(p12Der); | ||
var p12Cert = forge.pkcs12.pkcs12FromAsn1(p12Asn1, false, merchantConfig.getKeyPass()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 142 - 145 are already existing in 51 - 54.
If I need to make a change to this logic in future, I will have to change in both places, which is risky.
Better to create one function to do this.
2a3461e
to
a67aa34
Compare
d153125
to
f168e42
Compare
No description provided.