Skip to content

Commit

Permalink
Merge branch 'fix/VOMS-707' into develop
Browse files Browse the repository at this point in the history
* fix/VOMS-707:
  Sanitize subject in certificate request
  • Loading branch information
andreaceccanti committed Feb 10, 2016
2 parents 91faf00 + efbd5bf commit 7fff64b
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 7fff64b

Please sign in to comment.