MCPcopy Create free account
hub / github.com/apache/httpd / Credentials

Class Credentials

test/pyhttpd/certs.py:84–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84class Credentials:
85
86 def __init__(self, name: str, cert: Any, pkey: Any, issuer: 'Credentials' = None):
87 self._name = name
88 self._cert = cert
89 self._pkey = pkey
90 self._issuer = issuer
91 self._cert_file = None
92 self._pkey_file = None
93 self._store = None
94
95 @property
96 def name(self) -> str:
97 return self._name
98
99 @property
100 def subject(self) -> x509.Name:
101 return self._cert.subject
102
103 @property
104 def key_type(self):
105 if isinstance(self._pkey, RSAPrivateKey):
106 return f"rsa{self._pkey.key_size}"
107 elif isinstance(self._pkey, EllipticCurvePrivateKey):
108 return f"{self._pkey.curve.name}"
109 else:
110 raise Exception(f"unknown key type: {self._pkey}")
111
112 @property
113 def private_key(self) -> Any:
114 return self._pkey
115
116 @property
117 def certificate(self) -> Any:
118 return self._cert
119
120 @property
121 def cert_pem(self) -> bytes:
122 return self._cert.public_bytes(Encoding.PEM)
123
124 @property
125 def pkey_pem(self) -> bytes:
126 return self._pkey.private_bytes(
127 Encoding.PEM,
128 PrivateFormat.TraditionalOpenSSL if self.key_type.startswith('rsa') else PrivateFormat.PKCS8,
129 NoEncryption())
130
131 @property
132 def issuer(self) -> Optional['Credentials']:
133 return self._issuer
134
135 def set_store(self, store: 'CertStore'):
136 self._store = store
137
138 def set_files(self, cert_file: str, pkey_file: str = None):
139 self._cert_file = cert_file
140 self._pkey_file = pkey_file
141

Callers 4

load_credentialsMethod · 0.70
_make_ca_credentialsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected