Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

monu-kumar-visa
Copy link
Contributor

No description provided.

}

if (this.mleForRequestPublicCertPath !== null && this.mleForRequestPublicCertPath !== undefined) {
var certFile = path.resolve(path.join(this.mleForRequestPublicCertPath));
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

} catch (err) {
logger.warn("MLE certificate file not found or not readable: " + mleCertPath);
return null;
}
Copy link
Contributor

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.

Copy link
Contributor

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.

mleCert = loadCertificateFromPem(merchantConfig, mleCertPath);
}
else if (cacheKey.endsWith(Constants.MLE_CACHE_IDENTIFIER_FOR_P12_CERT)) {
mleCert = loadCertificateFromP12(merchantConfig, mleCertPath);
Copy link
Contributor

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?

Copy link
Contributor Author

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());

Copy link
Contributor

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.

@monu-kumar-visa monu-kumar-visa force-pushed the inbound-mle-for-http-signature branch from 2a3461e to a67aa34 Compare July 30, 2025 08:14
@monu-kumar-visa monu-kumar-visa force-pushed the inbound-mle-for-http-signature branch from d153125 to f168e42 Compare August 4, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants