protected function fetchCertificate()
    {
        $metadata = file_get_contents($this->getBaseUrl() . $this->getAdminSpMetadataFile());
        $deserializationContext = new DeserializationContext();
        $deserializationContext->getDocument()->loadXML($metadata);

        $ed = new EntityDescriptor();

        $ed->deserialize($deserializationContext->getDocument(), $deserializationContext);

        $certificate = $ed->getFirstSpSsoDescriptor()->getFirstKeyDescriptor(KeyDescriptor::USE_ENCRYPTION)
            ? $ed->getFirstSpSsoDescriptor()->getFirstKeyDescriptor(KeyDescriptor::USE_ENCRYPTION)
                ->getCertificate()
                ->toPem()
            : $ed->getFirstSpSsoDescriptor()->getFirstKeyDescriptor(KeyDescriptor::USE_SIGNING)
                ->getCertificate()
                ->toPem();

        return $certificate;
    }