Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BLasan committed Aug 18, 2023
1 parent ec4d243 commit d340b62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public MutualSSLAuthenticator(String apiLevelPolicy, boolean isMandatory, String
for (String certificatePart : certificateParts) {
int tierDivisionIndex = certificatePart.lastIndexOf("=");
if (tierDivisionIndex > 0) {
String uniqueIdentifier = certificatePart.substring(0, tierDivisionIndex).trim();
String uniqueIdentifier = certificatePart.substring(0, tierDivisionIndex)
.replaceAll("&", "&")
.replaceAll("&lt;", "<")
.replaceAll("&gt;", ">")
.trim();

Check warning on line 82 in components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/authenticator/MutualSSLAuthenticator.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/authenticator/MutualSSLAuthenticator.java#L78-L82

Added lines #L78 - L82 were not covered by tests
String tier = certificatePart.substring(tierDivisionIndex + 1);
certificates.put(uniqueIdentifier, tier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ public String getUniqueIdentifierOfCertificate(String certificate) {
Certificate generatedCertificate = cf.generateCertificate(serverCert);
X509Certificate x509Certificate = (X509Certificate) generatedCertificate;
uniqueIdentifier = x509Certificate.getSerialNumber() + "_" + x509Certificate.getIssuerDN();
uniqueIdentifier = uniqueIdentifier.replaceAll(",", "#").replaceAll("\"", "'");
uniqueIdentifier = uniqueIdentifier.replaceAll(",", "#").replaceAll("\"", "'")
.replaceAll("&", "&amp;")
.replaceAll("<", "&lt;").replaceAll(">", "&gt;");

Check warning on line 622 in components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/CertificateMgtUtils.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/CertificateMgtUtils.java#L620-L622

Added lines #L620 - L622 were not covered by tests
}
} catch (CertificateException e) {
log.error("Error while getting serial number of the certificate.", e);
Expand Down

0 comments on commit d340b62

Please sign in to comment.