Skip to content

Commit

Permalink
Sanitize subject in certificate request
Browse files Browse the repository at this point in the history
Trim whitespace & remove newlines

Issue: https://issues.infn.it/jira/browse/VOMS-707
  • Loading branch information
andreaceccanti committed Feb 10, 2016
1 parent 7f87ef2 commit efbd5bf
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public void validate() {
return;
}

if (dao.find(cert) != null)
if (dao.find(cert) != null){
addFieldError("certificateFile", "Certificate already bound!");
}

subject = DNUtil.getOpenSSLSubject(cert.getSubjectX500Principal());
caSubject = DNUtil.getOpenSSLSubject(cert.getIssuerX500Principal());
Expand All @@ -94,6 +95,14 @@ public void validate() {

} else if (subject != null && !"".equals(subject) && !caSubject.equals("-1")) {

// Remove whitespace and newlines from subject
subject=subject.trim().replace("\n", "").replace("\r", "");

if (subject.equals("")){
addFieldError("subject", "Please provide a suitable subject");
return;
}

if (dao.findByDNCA(subject, caSubject) != null) {
addFieldError("subject", "Certificate already bound!");
addFieldError("caSubject", "Certificate already bound!");
Expand Down

0 comments on commit efbd5bf

Please sign in to comment.