From 9b913502db62b75423f64a5834aa5347ab793af2 Mon Sep 17 00:00:00 2001 From: MB73904 Date: Fri, 31 May 2024 21:41:12 -0300 Subject: [PATCH] Fix SAML read Certificate and private key --- .../auth/saml/conf/ConfigurationService.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-sso/modules/guacamole-auth-sso-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java b/extensions/guacamole-auth-sso/modules/guacamole-auth-sso-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java index 47ead88208..1815c1209a 100644 --- a/extensions/guacamole-auth-sso/modules/guacamole-auth-sso-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java +++ b/extensions/guacamole-auth-sso/modules/guacamole-auth-sso-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java @@ -371,7 +371,13 @@ public int getAuthenticationTimeout() throws GuacamoleException { * If the X.509 certificate cannot be parsed. */ public File getCertificateFile() throws GuacamoleException { - return environment.getProperty(SAML_X509_CERT_PATH); + File certificate = null; + try { + certificate = environment.getProperty(SAML_X509_CERT_PATH).getCanonicalFile(); + } catch (IOException | GuacamoleException e) { + e.printStackTrace(); + } + return certificate; } /** @@ -387,7 +393,13 @@ public File getCertificateFile() throws GuacamoleException { * If the private key file cannot be parsed. */ public File getPrivateKeyFile() throws GuacamoleException { - return environment.getProperty(SAML_PRIVATE_KEY_PATH); + File privateKey = null; + try { + privateKey = environment.getProperty(SAML_PRIVATE_KEY_PATH).getCanonicalFile(); + } catch (IOException | GuacamoleException e) { + e.printStackTrace(); + } + return privateKey; } /** @@ -480,7 +492,7 @@ public Saml2Settings getSamlSettings() throws GuacamoleException { readFileContentsIntoString(privateKeyFile, "Private Key")); // If a certificate file is set, load the value into the builder now - File certificateFile = getCertificateFile(); + File certificateFile = getCertificateFile(); if (certificateFile != null) samlMap.put(SettingsBuilder.SP_X509CERT_PROPERTY_KEY, readFileContentsIntoString(certificateFile, "X.509 Certificate"));