private function generate_signature( $content, $private_key_pem, $signature_alg = "SHA256" )
	{
		// The function openssl_pkey_get_private always works with URLs so if necessary convert
		// the $private_key_pem variable to a URL using a 'file' scheme.  If there is no scheme
		// or the scheme is a letter A-Z then a local path is being used and needs converting.
		$parts = parse_url( $private_key_pem );
		if ( ( ! isset( $parts['scheme'] ) || preg_match( "/^[A-Z]$/", $parts['scheme'] ) ) && ! isset( $parts['host'] ) )
		{
			$private_key_pem = "file://";
			if ( isset( $parts['scheme'] ) ) $private_key_pem .= $parts['scheme'] . ":";
			$private_key_pem .= $parts['path'];
		}

		$private_key = openssl_pkey_get_private( $private_key_pem );

		if ( $private_key === false )
		{
			$message = "Unable to create a key id from the private key resource $pem\n" . openssl_error_string();
			throw new \Exception( $message );
		}

		$signature = null;

		$result = openssl_sign( $content, $signature, $private_key, $signature_alg );
		if ( ! $result )
		{
			$message = "Error to signing: " . openssl_error_string();
		}

		openssl_free_key( $private_key );

		if ( ! $result )
			throw new \Exception( $message );

			return base64_encode( $signature );
	}