diff --git a/modules/oauth/lib/Consumer.php b/modules/oauth/lib/Consumer.php
index 02f649eaf31a380e5d3fc09d735653e3533b2f3d..dbea3586ee3eae1bb21acfef5d57742a510bbb6a 100644
--- a/modules/oauth/lib/Consumer.php
+++ b/modules/oauth/lib/Consumer.php
@@ -154,9 +154,9 @@ class sspmod_oauth_Consumer
                 'header' => 'Content-Type: application/x-www-form-urlencoded',
             ),
         );
-        $context = stream_context_create($opts);
+
         try {
-            $response = \SimpleSAML\Utils\HTTP::fetch($url, $context);
+            $response = \SimpleSAML\Utils\HTTP::fetch($url, $opts);
         } catch (\SimpleSAML_Error_Exception $e) {
             throw new SimpleSAML_Error_Exception('Failed to push definition file to ' . $url);
         }