File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 44from cryptography .hazmat .primitives import serialization
55from cryptography .hazmat .primitives .asymmetric import rsa
66
7+ from ...dumper import _serialize_model_to_json
78from ...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
You can’t perform that action at this time.
0 commit comments