Python cryptography.x509.oid.NameOID.EMAIL_ADDRESS Examples

The following are 1 code examples of cryptography.x509.oid.NameOID.EMAIL_ADDRESS(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cryptography.x509.oid.NameOID , or try the search function .
Example #1
Source File: cert_manager.py    From SROS-grpc-services with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def subject_name(self):
        attribute_list = []
        if self.common_name:
            attribute_list.append(
                x509.NameAttribute(
                    NameOID.COMMON_NAME, text_type(self.common_name)
                )
            )
        if self.organization:
            attribute_list.append(
                x509.NameAttribute(
                    NameOID.ORGANIZATION_NAME, text_type(self.organization)
                )
            )
        if self.organizational_unit:
            attribute_list.append(
                x509.NameAttribute(
                    NameOID.ORGANIZATIONAL_UNIT_NAME,
                    text_type(self.organizational_unit),
                )
            )
        if self.country:
            attribute_list.append(
                x509.NameAttribute(
                    NameOID.COUNTRY_NAME, text_type(self.country)
                )
            )
        if self.state:
            attribute_list.append(
                x509.NameAttribute(
                    NameOID.STATE_OR_PROVINCE_NAME, text_type(self.state)
                )
            )
        if self.city:
            attribute_list.append(
                x509.NameAttribute(NameOID.LOCALITY_NAME, text_type(self.city))
            )
        if self.email_id:
            attribute_list.append(
                x509.NameAttribute(
                    NameOID.EMAIL_ADDRESS, text_type(self.email_id)
                )
            )
        return x509.Name(attribute_list)