Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
347129b7
Unverified
Commit
347129b7
authored
7 years ago
by
Thijs Kinkhorst
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #725 from bajnokk/bug/mdx-break
Make MDQ more robust on errors (fixes #723)
parents
71a90aa9
124f93d2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/SimpleSAML/Metadata/Sources/MDQ.php
+20
-7
20 additions, 7 deletions
lib/SimpleSAML/Metadata/Sources/MDQ.php
lib/SimpleSAML/Utils/HTTP.php
+1
-1
1 addition, 1 deletion
lib/SimpleSAML/Utils/HTTP.php
with
21 additions
and
8 deletions
lib/SimpleSAML/Metadata/Sources/MDQ.php
+
20
−
7
View file @
347129b7
...
...
@@ -262,7 +262,8 @@ class MDQ extends \SimpleSAML_Metadata_MetaDataStorageSource
*
* @return array An associative array with metadata for the given entity, or NULL if we are unable to
* locate the entity.
* @throws \Exception If an error occurs while downloading metadata, validating the signature or writing to cache.
* @throws \Exception If an error occurs while validating the signature or the metadata is in an
* incorrect set.
*/
public
function
getMetaData
(
$index
,
$set
)
{
...
...
@@ -272,7 +273,13 @@ class MDQ extends \SimpleSAML_Metadata_MetaDataStorageSource
Logger
::
info
(
__CLASS__
.
': loading metadata entity ['
.
$index
.
'] from ['
.
$set
.
']'
);
// read from cache if possible
$data
=
$this
->
getFromCache
(
$set
,
$index
);
try
{
$data
=
$this
->
getFromCache
(
$set
,
$index
);
}
catch
(
\Exception
$e
)
{
Logger
::
error
(
$e
->
getMessage
());
// proceed with fetching metadata even if the cache is broken
$data
=
null
;
}
if
(
$data
!==
null
&&
array_key_exists
(
'expires'
,
$data
)
&&
$data
[
'expires'
]
<
time
())
{
// metadata has expired
...
...
@@ -292,14 +299,15 @@ class MDQ extends \SimpleSAML_Metadata_MetaDataStorageSource
try
{
$xmldata
=
HTTP
::
fetch
(
$mdq_url
);
}
catch
(
\Exception
$e
)
{
Logger
::
warning
(
'Fetching metadata for '
.
$index
.
': '
.
$e
->
getMessage
());
// Avoid propagating the exception, make sure we can handle the error later
$xmldata
=
false
;
}
if
(
empty
(
$xmldata
))
{
$error
=
error_get_last
();
throw
new
\Exception
(
'Error downloading metadata for "'
.
$index
.
'" from "'
.
$mdq_url
.
'": '
.
$error
[
'message'
]
)
;
Logger
::
info
(
'Unable to fetch metadata for "'
.
$index
.
'" from '
.
$mdq_url
.
': '
.
(
is_array
(
$error
)
?
$error
[
'message'
]
:
'no error available'
));
return
null
;
}
/** @var string $xmldata */
...
...
@@ -317,7 +325,12 @@ class MDQ extends \SimpleSAML_Metadata_MetaDataStorageSource
throw
new
\Exception
(
__CLASS__
.
': no metadata for set "'
.
$set
.
'" available from "'
.
$index
.
'".'
);
}
$this
->
writeToCache
(
$set
,
$index
,
$data
);
try
{
$this
->
writeToCache
(
$set
,
$index
,
$data
);
}
catch
(
\Exception
$e
)
{
// Proceed without writing to cache
Logger
::
error
(
'Error writing MDQ result to cache: '
.
$e
->
getMessage
());
}
return
$data
;
}
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Utils/HTTP.php
+
1
−
1
View file @
347129b7
...
...
@@ -444,7 +444,7 @@ class HTTP
}
$context
=
stream_context_create
(
$context
);
$data
=
file_get_contents
(
$url
,
false
,
$context
);
$data
=
@
file_get_contents
(
$url
,
false
,
$context
);
if
(
$data
===
false
)
{
$error
=
error_get_last
();
throw
new
\SimpleSAML_Error_Exception
(
'Error fetching '
.
var_export
(
$url
,
true
)
.
':'
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment