components/test/data/cast_certificate/certificates/generate_policies_tests.py
def generate_policies_chain(intermediate_policies, leaf_policies):
  """Creates a certificate chain and writes it to a PEM file (in the current
  directory).

  The chain has 3 certificates (root, intermediate, leaf). The root has no
  policies extension, whereas the intermediate has policies given by
  |intermediate_policies| and the leaf has policies given by |leaf_policies|.

  The policies are specified as a list, with the empty list meaning no policies
  extension. Values in the list should be one of the OID constants (AUDIO_ONLY,
  ANY_POLICY).

  The name of the generated file is a human-readable serialization of this
  function's parameters.
  """

  # Self-signed root certificate.
  root = common.create_self_signed_root_certificate('Root')
  root.set_validity_range(JAN_2015, JAN_2018)

  # Intermediate certificate.
  intermediate = common.create_intermediate_certificate('Intermediate', root)
  set_policies_from_list(intermediate, intermediate_policies)
  intermediate.set_validity_range(JAN_2015, JAN_2018)

  # Leaf certificate.
  leaf = common.create_end_entity_certificate('Leaf', intermediate)
  set_policies_from_list(leaf, leaf_policies)
  leaf.get_extensions().set_property('extendedKeyUsage', 'clientAuth')
  leaf.set_validity_range(JAN_2015, JAN_2018)

  chain = [leaf, intermediate, root]
  chain_description = """Cast certificate chain with the following policies:

  Root:           policies={}
  Intermediate:   policies={%s}
  Leaf:           policies={%s}""" % (', '.join(intermediate_policies),
                                      ', '.join(leaf_policies))

  chain_file_name = 'policies_ica_%s_leaf_%s.pem' % (
      policies_to_filename(intermediate_policies),
      policies_to_filename(leaf_policies))

  common.write_chain(chain_description, chain, chain_file_name)
Creates a certificate chain and writes it to a PEM file (in the current
  directory).

  The chain has 3 certificates (root, intermediate, leaf). The root has no
  policies extension, whereas the intermediate has policies given by
  |intermediate_policies| and the leaf has policies given by |leaf_policies|.

  The policies are specified as a list, with the empty list meaning no policies
  extension. Values in the list should be one of the OID constants (AUDIO_ONLY,
  ANY_POLICY).

  The name of the generated file is a human-readable serialization of this
  function's parameters.
  
Creates a certificate chain and writes it to a PEM file (in the current
directory).

The chain has 3 certificates (root, intermediate, leaf). The root has no
policies extension, whereas the intermediate has policies given by
|intermediate_policies| and the leaf has policies given by |leaf_policies|.

The policies are specified as a list, with the empty list meaning no policies
extension. Values in the list should be one of the OID constants (AUDIO_ONLY,
ANY_POLICY).

The name of the generated file is a human-readable serialization of this
function's parameters.
Creates a certificate chain and writes it to a PEM file ( in the current directory ) . The chain has 3 certificates ( root intermediate leaf ) . The root has no policies extension whereas the intermediate has policies given by |intermediate_policies| and the leaf has policies given by |leaf_policies| . The policies are specified as a list with the empty list meaning no policies extension . Values in the list should be one of the OID constants ( AUDIO_ONLY ANY_POLICY ) . The name of the generated file is a human - readable serialization of this function ' s parameters .
def generate_policies_chain(intermediate_policies, leaf_policies):
  root = common.create_self_signed_root_certificate('Root')
  root.set_validity_range(JAN_2015, JAN_2018)
  intermediate = common.create_intermediate_certificate('Intermediate', root)
  set_policies_from_list(intermediate, intermediate_policies)
  intermediate.set_validity_range(JAN_2015, JAN_2018)
  leaf = common.create_end_entity_certificate('Leaf', intermediate)
  set_policies_from_list(leaf, leaf_policies)
  leaf.get_extensions().set_property('extendedKeyUsage', 'clientAuth')
  leaf.set_validity_range(JAN_2015, JAN_2018)
  chain = [leaf, intermediate, root]
  chain_description = """Cast certificate chain with the following policies:
  Root:           policies={}
  Intermediate:   policies={%s}
  Leaf:           policies={%s}""" % (', '.join(intermediate_policies),
                                      ', '.join(leaf_policies))
  chain_file_name = 'policies_ica_%s_leaf_%s.pem' % (
      policies_to_filename(intermediate_policies),
      policies_to_filename(leaf_policies))
  common.write_chain(chain_description, chain, chain_file_name)
def generate_policies_chain ( intermediate_policies , leaf_policies ) : root = common . create_self_signed_root_certificate ( 'Root' ) root . set_validity_range ( JAN_2015 , JAN_2018 ) intermediate = common . create_intermediate_certificate ( 'Intermediate' , root ) set_policies_from_list ( intermediate , intermediate_policies ) intermediate . set_validity_range ( JAN_2015 , JAN_2018 ) leaf = common . create_end_entity_certificate ( 'Leaf' , intermediate ) set_policies_from_list ( leaf , leaf_policies ) leaf . get_extensions ( ) . set_property ( 'extendedKeyUsage' , 'clientAuth' ) leaf . set_validity_range ( JAN_2015 , JAN_2018 ) chain = [ leaf , intermediate , root ] chain_description = """Cast certificate chain with the following policies:

  Root:           policies={}
  Intermediate:   policies={%s}
  Leaf:           policies={%s}""" % ( ', ' . join ( intermediate_policies ) , ', ' . join ( leaf_policies ) ) chain_file_name = 'policies_ica_%s_leaf_%s.pem' % ( policies_to_filename ( intermediate_policies ) , policies_to_filename ( leaf_policies ) ) common . write_chain ( chain_description , chain , chain_file_name )
Creates a certificate chain and writes it to a PEM file (in the current
directory).
Creates a certificate chain and writes it to a PEM file ( in the current directory ) .
"""Creates a certificate chain and writes it to a PEM file (in the current
  directory).

  The chain has 3 certificates (root, intermediate, leaf). The root has no
  policies extension, whereas the intermediate has policies given by
  |intermediate_policies| and the leaf has policies given by |leaf_policies|.

  The policies are specified as a list, with the empty list meaning no policies
  extension. Values in the list should be one of the OID constants (AUDIO_ONLY,
  ANY_POLICY).

  The name of the generated file is a human-readable serialization of this
  function's parameters.
  """ # Self-signed root certificate. # Intermediate certificate. # Leaf certificate.
intermediate_policies
leaf_policies