GUACAMOLE-839: Merge corrected handling of possible null values within SSL/TLS client auth support.

This commit is contained in:
James Muehlner
2023-03-08 10:48:02 -08:00
committed by GitHub
2 changed files with 17 additions and 1 deletions

View File

@@ -253,7 +253,20 @@ public class SSLClientAuthenticationResource extends SSOResource {
try (Reader reader = new StringReader(new String(certificate, StandardCharsets.UTF_8))) { try (Reader reader = new StringReader(new String(certificate, StandardCharsets.UTF_8))) {
PEMParser parser = new PEMParser(reader); PEMParser parser = new PEMParser(reader);
cert = (X509CertificateHolder) parser.readObject(); Object object = parser.readObject();
// Verify received data is indeed an X.509 certificate
if (object == null || !(object instanceof X509CertificateHolder))
throw new GuacamoleClientException("Certificate did not "
+ "contain an X.509 certificate.");
// Verify sanity of received certificate (there should be only
// one object here)
if (parser.readObject() != null)
throw new GuacamoleClientException("Certificate contains "
+ "more than a single X.509 certificate.");
cert = (X509CertificateHolder) object;
// Verify certificate is valid (it should be given pre-validation // Verify certificate is valid (it should be given pre-validation
// from SSL termination, but it's worth rechecking for sanity) // from SSL termination, but it's worth rechecking for sanity)

View File

@@ -45,6 +45,9 @@ public abstract class WildcardURIGuacamoleProperty extends URIGuacamoleProperty
@Override @Override
public URI parseValue(String value) throws GuacamoleException { public URI parseValue(String value) throws GuacamoleException {
if (value == null)
return null;
// Verify wildcard prefix is present // Verify wildcard prefix is present
Matcher matcher = WILDCARD_URI_PATTERN.matcher(value); Matcher matcher = WILDCARD_URI_PATTERN.matcher(value);
if (matcher.matches()) { if (matcher.matches()) {