
    b	                     Z    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SKJ	r	  SSK
r
S rg)	z!Helpers for parsing certificates.    )absolute_import)division)unicode_literalsN)
exceptions)filesc                 >   [         R                  " U 5      nSU;   a  UR                  SSS5      nUR                  SSS5      nSU;   a&  [        R                  " SSR                  U 5      5      e UR                  SS5      R                  SS5      n[        R                  " [        R                  " U5      5      n[        R                  " U5      nXB:w  a  [        S	5      e U$ U$ ! [         a+  n[        R                  " SS
R                  X5      5      eSnAff = f)a  Read certificate_file and return the certificate in DER encoding.

Args:
  certificate_file: A file handle to the certificate in PEM or DER format.

Returns:
  The certificate in DER encoding.

Raises:
  BadArgumentException: The provided certificate failed to parse as a PEM.
s   -----BEGIN CERTIFICATE-----       s   -----END CERTIFICATE-----certificate_filez8Cannot place multiple certificates in the same file : {}      
zNon-base64 digit found.z:Recognized {} as a PEM file but failed during parsing : {}N)r   ReadBinaryFileContentsreplacer   BadArgumentExceptionformatbase64	b64decodesixensure_binary	b64encode
ValueError	Exception)r   datacertb64decodedencodedes         +lib/googlecloudsdk/command_lib/kms/certs.pyGetDerCertificater      s    
	%	%&6	7$#t+ll93BGoo:CCG%0++

D
K
K ! !$s+33E3?g   !2!27!;<g  )g		233 
 NK  $++

F
M
M#$ $$s   0A2C' '
D1&DD)__doc__
__future__r   r   r   r   googlecloudsdk.callioper   googlecloudsdk.core.utilr   r   r    r	   r   <module>r%      s$    ( &  '  . * 
%r	   