certified.encode — Certificate Encoding
Helpers for building x509 names, subject alternative names, and certificate fields.
Also defines PrivIface, the key-type abstraction used throughout the library.
Name builders
person_name
Build and return an x509.Name suitable for an individual.
Source code in certified/encode.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
org_name
Build and return an x509.Name suitable for an organization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organization_name
|
str
|
Sets the "Organization Name" (O) attribute on the certificate. |
required |
unit_name
|
str
|
Sets the "Organization Unit Name" (OU) attribute on the certificate. |
required |
common_name
|
Optional[str]
|
Sets the "Common Name" of the certificate. This is a legacy field that used to be used to check identity. It's an arbitrary string with poorly-defined semantics, so modern programs are supposed to ignore it. But it might be useful if you need to test how your software handles legacy or buggy certificates. |
None
|
location
|
Location
|
Optionally a tuple containing: (country_code, state_or_province, city_or_locality) |
(None, None, None)
|
pseudonym
|
Optional[str]
|
Used here to denote whether this is a signing key. |
None
|
Source code in certified/encode.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
append_pseudonym
Append a NameOID.PSEUDONYM field to the name with the given value.
Used by certified to create a unique name for the signing certificate by appending ps = "Signing Certificate"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Name
|
the base name |
required |
ps
|
str
|
appended pseudonym |
required |
Source code in certified/encode.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
SAN
Build a subject alternative name field. Examples include:
-
emails: The emails that this certificate will be valid for.
- Email address:
example@example.com
- Email address:
-
hosts:
- Regular hostname:
example.com - Wildcard hostname:
*.example.com - International Domain Name (IDN):
café.example.com - IDN in A-label form:
xn--caf-dma.example.com - IPv4 address:
127.0.0.1 - IPv6 address:
::1 - IPv4 network:
10.0.0.0/8 - IPv6 network:
2001::/16
- Regular hostname:
-
uris:
- "https://dx.doi.org/10.1.1.1"
Source code in certified/encode.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
Key type interface
PrivIface
Source code in certified/encode.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
Certificate field helpers
cert_builder_common
Common part of the certificate building process.
Factored into some re-usable code that automatically sets up valid date ranges and checks that your name won't collide with what you're signing.
Source code in certified/encode.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
hash_for_pubkey
Source code in certified/encode.py
89 90 91 92 93 | |
rfc4514name
Source code in certified/encode.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
get_is_ca
Source code in certified/encode.py
455 456 457 458 459 460 461 462 463 | |
get_path_length
Source code in certified/encode.py
447 448 449 450 451 452 453 | |
get_aki
Collect the SubjectKeyIdentifier from a certificate and return it as an AuthorityKeyIdentifier. The content should be the same, but they have different header / wrappers.
Source code in certified/encode.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
get_urls
Source code in certified/encode.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |