if (actualPort != null) {
try {
actualPortInt = Integer.valueOf(actualPort);
}
catch (NumberFormatException e) {
throw new ValidationErrorsException("port", "Port must be an integer");
}
}
Certificate[] chain;
try {
chain = retrieveCertificates(remoteStorageContext, actualHost, actualPortInt, actualProtocolHint);
}
catch (Exception e) {
String errorMessage = e.getMessage();
if (e instanceof UnknownHostException) {
errorMessage = "Unknown host '" + actualHost + "'";
}
throw new NotFoundException(errorMessage);
}
if (chain == null || chain.length == 0) {
throw new NotFoundException(
"Could not retrieve an SSL certificate from " + actualHost + ":" + actualPortInt
);
}
return asCertificateXO(chain[0], isInNexusSSLTrustStore(chain[0]));
}
throw new ValidationErrorsException("One of repositoryId or host/port should be specified");
}