
    h                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  Sr\R                  " SR                  \5      5      rS	 rS
 rg)z%PEM utilities for Privateca commands.    )absolute_import)division)unicode_literalsN)
exceptionszR-----BEGIN CERTIFICATE-----\n(?:[a-zA-Z0-9+/=]+\r?\n)+-----END CERTIFICATE-----\s*z^({})+$c                    [         R                  " [        U 5      (       d  [        R                  " SS5      e[         R
                  " [        U 5      n[        [        U5      5       H  nX   R                  5       S-   X'   M     U$ )a6  Validates and parses a pem_chain string into a list of certs.

Args:
  pem_chain: The string represting the pem_chain.

Returns:
  A list of the certificates that make up the chain, in the same order
  as the input.

Raises:
  exceptions.InvalidArgumentException if the pem_chain is in an unexpected
  format.
z	pem-chainz7The pem_chain you provided was in an unexpected format.
)
rematch_PEM_CHAIN_REr   InvalidArgumentExceptionfindall_PEM_CERT_RErangelenstrip)	pem_chaincertsis      5lib/googlecloudsdk/command_lib/privateca/pem_utils.pyValidateAndParsePemChainr      sq     
-	+	+

-
-NP P **\9
-%Uax~~$&EH  
,    c                 l    U  Vs/ s H  oR                  5       PM     nnSR                  U5      $ s  snf )zFormats a pem chain for output with exactly 1 newline character between each cert.

Args:
  pem_chain: The list of certificate strings to output

Returns:
  The string value of all certificates appended together for output.
r   )r   join)r   certstripped_pem_chains      r   PemChainForOutputr   9   s2     2;;

;	%	&& <s   1)__doc__
__future__r   r   r   r	   googlecloudsdk.callioper   r   compileformatr   r   r    r   r   <module>r#      sH    , &  ' 	 .  

:,,\:;4
'r   