Skip to content

Commit 265db7f

Browse files
authored
fix: re re fix: #2
to me: 2回ともForce Pushで消失してたぞ
1 parent 9d07ea6 commit 265db7f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/apmodel/extra/security/cryptographickey.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from cryptography.hazmat.primitives import serialization
55
from cryptography.hazmat.primitives.asymmetric import rsa
66

7+
from ...dumper import _serialize_model_to_json
78
from ...types import Undefined, ActivityPubModel
89

910
@dataclass
@@ -22,4 +23,13 @@ def __post_init__(self):
2223
if isinstance(pub_key, rsa.RSAPublicKey):
2324
self.publicKeyPem = pub_key
2425
else:
25-
raise ValueError("Unsupported Key: {}".format(type(pub_key)))
26+
raise ValueError("Unsupported Key: {}".format(type(pub_key)))
27+
28+
def to_json(self):
29+
if isinstance(self.publicKeyPem, rsa.RSAPublicKey):
30+
self.publicKeyPem = self.publicKeyPem.public_bytes(
31+
encoding=serialization.Encoding.PEM,
32+
format=serialization.PublicFormat.SubjectPublicKeyInfo
33+
).decode("utf-8")
34+
data = _serialize_model_to_json(self)
35+
return data

0 commit comments

Comments
 (0)