You are here

public static function Utilities::sanitize_certificate in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

4 calls to Utilities::sanitize_certificate()
IdentityProviders::parseSigningCertificate in src/MetadataReader.php
MiniorangeSPInformation::mo_saml_upload_certificate in src/Form/MiniorangeSPInformation.php
MiniorangeSPInformation::submitForm in src/Form/MiniorangeSPInformation.php
Configure IdP.
Utilities::findCertificate in src/Utilities.php

File

src/Utilities.php, line 608

Class

Utilities
This file is part of miniOrange SAML plugin.

Namespace

Drupal\miniorange_saml

Code

public static function sanitize_certificate($certificate, $getRaw = FALSE) {
  $certificate = preg_replace("/[\r\n]+/", "", $certificate);
  $certificate = str_replace("-", "", $certificate);
  $certificate = str_replace("BEGIN CERTIFICATE", "", $certificate);
  $certificate = str_replace("END CERTIFICATE", "", $certificate);
  $certificate = str_replace(" ", "", $certificate);
  if ($getRaw) {
    return $certificate;
  }
  $certificate = chunk_split($certificate, 64, "\r\n");
  $certificate = "-----BEGIN CERTIFICATE-----\r\n" . $certificate . "-----END CERTIFICATE-----";
  return $certificate;
}