diff --git a/src/signed-xml.ts b/src/signed-xml.ts
index 53ef3ec7..98bef161 100644
--- a/src/signed-xml.ts
+++ b/src/signed-xml.ts
@@ -194,7 +194,12 @@ export class SignedXml {
if (publicCertMatches.length > 0) {
x509Certs = publicCertMatches
- .map((c) => `${utils.pemToDer(c).toString("base64")}`)
+ .map(
+ (c) =>
+ `<${prefix}X509Certificate>${utils
+ .pemToDer(c)
+ .toString("base64")}${prefix}X509Certificate>`,
+ )
.join("");
}
diff --git a/test/signature-unit-tests.spec.ts b/test/signature-unit-tests.spec.ts
index bca1fb00..dd916fae 100644
--- a/test/signature-unit-tests.spec.ts
+++ b/test/signature-unit-tests.spec.ts
@@ -555,15 +555,13 @@ describe("Signature unit tests", function () {
const xml = '';
const sig = new SignedXml();
+ sig.publicCert = fs.readFileSync("./test/static/client_public.pem");
sig.CanonicalizationAlgorithms["http://DummyTransformation"] = DummyTransformation;
sig.CanonicalizationAlgorithms["http://DummyCanonicalization"] = DummyCanonicalization;
sig.HashAlgorithms["http://dummyDigest"] = DummyDigest;
sig.SignatureAlgorithms["http://dummySignatureAlgorithm"] = DummySignatureAlgorithm;
sig.signatureAlgorithm = "http://dummySignatureAlgorithm";
- sig.getKeyInfoContent = function () {
- return "dummy key info";
- };
sig.canonicalizationAlgorithm = "http://DummyCanonicalization";
sig.privateKey = "";
@@ -615,11 +613,13 @@ describe("Signature unit tests", function () {
"" +
"dummy signature" +
"" +
- "dummy key info" +
+ "" +
+ "MIIBxDCCAW6gAwIBAgIQxUSXFzWJYYtOZnmmuOMKkjANBgkqhkiG9w0BAQQFADAWMRQwEgYDVQQDEwtSb290IEFnZW5jeTAeFw0wMzA3MDgxODQ3NTlaFw0zOTEyMzEyMzU5NTlaMB8xHTAbBgNVBAMTFFdTRTJRdWlja1N0YXJ0Q2xpZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+L6aB9x928noY4+0QBsXnxkQE4quJl7c3PUPdVu7k9A02hRG481XIfWhrDY5i7OEB7KGW7qFJotLLeMec/UkKUwCgv3VvJrs2nE9xO3SSWIdNzADukYh+Cxt+FUU6tUkDeqg7dqwivOXhuOTRyOI3HqbWTbumaLdc8jufz2LhaQIDAQABo0swSTBHBgNVHQEEQDA+gBAS5AktBh0dTwCNYSHcFmRjoRgwFjEUMBIGA1UEAxMLUm9vdCBBZ2VuY3mCEAY3bACqAGSKEc+41KpcNfQwDQYJKoZIhvcNAQEEBQADQQAfIbnMPVYkNNfX1tG1F+qfLhHwJdfDUZuPyRPucWF5qkh6sSdWVBY5sT/txBnVJGziyO8DPYdu2fPMER8ajJfl" +
+ "" +
"" +
"";
- expect(expected, "wrong signature format").to.equal(signature);
+ expect(signature, "wrong signature format").to.equal(expected);
const signedXml = sig.getSignedXml();
const expectedSignedXml =
@@ -652,17 +652,19 @@ describe("Signature unit tests", function () {
"" +
"dummy signature" +
"" +
- "dummy key info" +
+ "" +
+ "MIIBxDCCAW6gAwIBAgIQxUSXFzWJYYtOZnmmuOMKkjANBgkqhkiG9w0BAQQFADAWMRQwEgYDVQQDEwtSb290IEFnZW5jeTAeFw0wMzA3MDgxODQ3NTlaFw0zOTEyMzEyMzU5NTlaMB8xHTAbBgNVBAMTFFdTRTJRdWlja1N0YXJ0Q2xpZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+L6aB9x928noY4+0QBsXnxkQE4quJl7c3PUPdVu7k9A02hRG481XIfWhrDY5i7OEB7KGW7qFJotLLeMec/UkKUwCgv3VvJrs2nE9xO3SSWIdNzADukYh+Cxt+FUU6tUkDeqg7dqwivOXhuOTRyOI3HqbWTbumaLdc8jufz2LhaQIDAQABo0swSTBHBgNVHQEEQDA+gBAS5AktBh0dTwCNYSHcFmRjoRgwFjEUMBIGA1UEAxMLUm9vdCBBZ2VuY3mCEAY3bACqAGSKEc+41KpcNfQwDQYJKoZIhvcNAQEEBQADQQAfIbnMPVYkNNfX1tG1F+qfLhHwJdfDUZuPyRPucWF5qkh6sSdWVBY5sT/txBnVJGziyO8DPYdu2fPMER8ajJfl" +
+ "" +
"" +
"" +
"";
- expect(expectedSignedXml, "wrong signedXml format").to.equal(signedXml);
+ expect(signedXml, "wrong signedXml format").to.equal(expectedSignedXml);
const originalXmlWithIds = sig.getOriginalXmlWithIds();
const expectedOriginalXmlWithIds =
'';
- expect(expectedOriginalXmlWithIds, "wrong OriginalXmlWithIds").to.equal(originalXmlWithIds);
+ expect(originalXmlWithIds, "wrong OriginalXmlWithIds").to.equal(expectedOriginalXmlWithIds);
});
it("signer creates correct signature values", function () {