-
Notifications
You must be signed in to change notification settings - Fork 716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SAML read Certificate and private key #990
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the problem you're encountering that is fixed by calling |
||
} catch (IOException | GuacamoleException e) { | ||
e.printStackTrace(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If an error should be logged, it should be logged by a That said, I think the proper thing to do here would be to just rethrow the |
||
} | ||
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this line was changed only by adding several spaces to the end. |
||
if (certificateFile != null) | ||
samlMap.put(SettingsBuilder.SP_X509CERT_PROPERTY_KEY, | ||
readFileContentsIntoString(certificateFile, "X.509 Certificate")); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will throw a
NullPointerException
ifgetProperty()
returnsnull
(if the property is not present). Same for the other call togetCanonicalFile()
.