Skip to content

Commit 0c722b8

Browse files
committed
key loader: x509: Remove
Signed-off-by: John Andersen <[email protected]>
1 parent 7a97a49 commit 0c722b8

File tree

5 files changed

+4
-154
lines changed

5 files changed

+4
-154
lines changed

docs/registration_policies.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,42 +66,12 @@ Simple drop rule based on claim content allowlist.
6666
{
6767
"$id": "https://schema.example.com/scitt-allowlist.schema.json",
6868
"$schema": "https://json-schema.org/draft/2020-12/schema",
69-
"required": ["issuer", "issuer_key"],
7069
"properties": {
7170
"issuer": {
7271
"type": "string",
7372
"enum": [
7473
"did:web:example.org"
7574
]
76-
},
77-
"issuer_key": {
78-
"type": "object",
79-
"required": ["content_type", "certificate"],
80-
"properties": {
81-
"content_type": {
82-
"type": "string",
83-
"enum": [
84-
"application/pkix-cert"
85-
]
86-
},
87-
"certificate": {
88-
"type": "object",
89-
"required": ["subject"],
90-
"properties": {
91-
"subject": {
92-
"type": "object",
93-
"properties": {
94-
"O": {
95-
"type": "string",
96-
"enum": [
97-
"SCITT Emulator"
98-
]
99-
}
100-
}
101-
}
102-
}
103-
}
104-
}
10575
}
10676
}
10777
}

scitt_emulator/key_loader_format_url_referencing_ssh_authorized_keys.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import jwcrypto.jwk
1515

1616
from scitt_emulator.did_helpers import did_web_to_url
17+
from scitt_emulator.key_helper_dataclasses import VerificationKey
18+
19+
CONTENT_TYPE = "application/key+ssh"
1720

1821

1922
def key_loader_format_url_referencing_ssh_authorized_keys(
@@ -40,7 +43,7 @@ def key_loader_format_url_referencing_ssh_authorized_keys(
4043
transforms=[key],
4144
original=key,
4245
original_content_type=CONTENT_TYPE,
43-
original_bytes=line.encode("utf-8"),
46+
original_bytes=line,
4447
original_bytes_encoding="utf-8",
4548
usable=False,
4649
cwt=None,

scitt_emulator/key_loader_format_url_referencing_x509.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@
1515
'did_key=scitt_emulator.key_loader_format_did_key:key_loader_format_did_key',
1616
'url_referencing_oidc_issuer=scitt_emulator.key_loader_format_url_referencing_oidc_issuer:key_loader_format_url_referencing_oidc_issuer',
1717
'url_referencing_ssh_authorized_keys=scitt_emulator.key_loader_format_url_referencing_ssh_authorized_keys:key_loader_format_url_referencing_ssh_authorized_keys',
18-
'url_referencing_x509=scitt_emulator.key_loader_format_url_referencing_x509:key_loader_format_url_referencing_x509',
1918
],
2019
'scitt_emulator.key_helpers.transforms_key_instances': [
2120
'transform_key_instance_cwt_cose_ec2_to_pycose_ec2=scitt_emulator.key_transforms:transform_key_instance_cwt_cose_ec2_to_pycose_ec2',
2221
'transform_key_instance_cryptography_ecc_public_to_jwcrypto_jwk=scitt_emulator:key_loader_format_did_key.transform_key_instance_cryptography_ecc_public_to_jwcrypto_jwk',
2322
'transform_key_instance_jwcrypto_jwk_to_cwt_cose=scitt_emulator.key_loader_format_url_referencing_oidc_issuer:transform_key_instance_jwcrypto_jwk_to_cwt_cose',
2423
],
2524
'scitt_emulator.key_helpers.verification_key_to_object': [
26-
# TODO 'to_object_did_key=scitt_emulator.key_loader_format_did_key:to_object_did_key',
27-
'to_object_x509=scitt_emulator.key_loader_format_url_referencing_x509:to_object_x509',
28-
# TODO 'to_object_ssh_authorized_keys=scitt_emulator.key_loader_format_url_referencing_ssh_authorized_keys:to_object_ssh_authorized_keys',
2925
'to_object_oidc_issuer=scitt_emulator.key_loader_format_url_referencing_oidc_issuer:to_object_oidc_issuer',
3026
],
3127
},

tests/test_cli.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99
import jwcrypto
1010
from flask import Flask, jsonify, send_file
1111
from werkzeug.serving import make_server
12-
from cryptography import x509
13-
from cryptography.x509.oid import NameOID
14-
from cryptography.hazmat.primitives import hashes
15-
from cryptography.hazmat.backends import default_backend
16-
from cryptography.hazmat.primitives.asymmetric import rsa
17-
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
18-
from jwcrypto import jwk, jws
19-
import datetime
2012
from scitt_emulator import cli, server
2113
from scitt_emulator.oidc import OIDCAuthMiddleware
2214

@@ -174,44 +166,6 @@ def create_flask_app_oidc_server(config):
174166
@app.route("/", methods=["GET"])
175167
def ssh_public_keys():
176168
from cryptography.hazmat.primitives import serialization
177-
key = app.config["key"]
178-
rsa_public_key = jwk.JWK.from_json(key.export_public())
179-
180-
# Convert the JWK to a public key
181-
public_key = rsa_public_key.get_op_key('verify')
182-
183-
# Create a builder for the X.509 certificate
184-
subject = issuer = x509.Name([
185-
x509.NameAttribute(NameOID.COUNTRY_NAME, "US"),
186-
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, "Oregon"),
187-
x509.NameAttribute(NameOID.LOCALITY_NAME, "Portland"),
188-
x509.NameAttribute(NameOID.ORGANIZATION_NAME, "SCITT Emulator"),
189-
x509.NameAttribute(NameOID.COMMON_NAME, "example.com"),
190-
])
191-
192-
cert_builder = x509.CertificateBuilder(
193-
subject_name=subject,
194-
issuer_name=issuer,
195-
public_key=public_key,
196-
serial_number=x509.random_serial_number(),
197-
not_valid_before=datetime.datetime.utcnow(),
198-
not_valid_after=datetime.datetime.utcnow() + datetime.timedelta(days=365), # Certificate valid for 1 year
199-
extensions=[]
200-
)
201-
202-
# Self-sign the certificate with the private key
203-
private_key_op = key.get_op_key('sign')
204-
cert = cert_builder.sign(private_key=private_key_op, algorithm=hashes.SHA256(), backend=default_backend())
205-
206-
# Serialize the certificate
207-
cert_pem = cert.public_bytes(encoding=Encoding.PEM)
208-
209-
# Display or save the PEM encoded certificate
210-
return send_file(
211-
io.BytesIO(cert_pem),
212-
mimetype="text/plain",
213-
)
214-
# TODO Re-enable ssh authorized_keys
215169
return send_file(
216170
io.BytesIO(
217171
serialization.load_pem_public_key(
@@ -224,9 +178,6 @@ def ssh_public_keys():
224178
mimetype="text/plain",
225179
)
226180

227-
# TODO Re-enable oidc/jwks
228-
return app
229-
230181
@app.route("/.well-known/openid-configuration", methods=["GET"])
231182
def openid_configuration():
232183
return jsonify(

0 commit comments

Comments
 (0)