summaryrefslogtreecommitdiff
path: root/src/remote/activitypub
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2020-01-20 04:51:44 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-01-20 04:51:44 +0900
commit46aaf8fa9a30cbe1c1410e59e70caa9e202c4cf0 (patch)
treebed7def06f02315a65a3eb736e70c5c8fa143935 /src/remote/activitypub
parentFix syuilo#5729 (#5732) (diff)
downloadsharkey-46aaf8fa9a30cbe1c1410e59e70caa9e202c4cf0.tar.gz
sharkey-46aaf8fa9a30cbe1c1410e59e70caa9e202c4cf0.tar.bz2
sharkey-46aaf8fa9a30cbe1c1410e59e70caa9e202c4cf0.zip
AP Actorの鍵とkeyIdのフォーマットの変更 (#5733)
* Node PKCS#8 * keyIdを#main-key形式に
Diffstat (limited to 'src/remote/activitypub')
-rw-r--r--src/remote/activitypub/renderer/key.ts10
-rw-r--r--src/remote/activitypub/renderer/person.ts2
-rw-r--r--src/remote/activitypub/request.ts2
3 files changed, 9 insertions, 5 deletions
diff --git a/src/remote/activitypub/renderer/key.ts b/src/remote/activitypub/renderer/key.ts
index 334e5e00cd..e792f487fd 100644
--- a/src/remote/activitypub/renderer/key.ts
+++ b/src/remote/activitypub/renderer/key.ts
@@ -1,10 +1,14 @@
import config from '../../../config';
import { ILocalUser } from '../../../models/entities/user';
import { UserKeypair } from '../../../models/entities/user-keypair';
+import { createPublicKey } from 'crypto';
-export default (user: ILocalUser, key: UserKeypair) => ({
- id: `${config.url}/users/${user.id}/publickey`,
+export default (user: ILocalUser, key: UserKeypair, postfix?: string) => ({
+ id: `${config.url}/users/${user.id}${postfix || '/publickey'}`,
type: 'Key',
owner: `${config.url}/users/${user.id}`,
- publicKeyPem: key.publicKey
+ publicKeyPem: createPublicKey(key.publicKey).export({
+ type: 'spki',
+ format: 'pem'
+ })
});
diff --git a/src/remote/activitypub/renderer/person.ts b/src/remote/activitypub/renderer/person.ts
index d4c018fb78..07a0eeed42 100644
--- a/src/remote/activitypub/renderer/person.ts
+++ b/src/remote/activitypub/renderer/person.ts
@@ -108,7 +108,7 @@ export async function renderPerson(user: ILocalUser) {
image: banner ? renderImage(banner) : null,
tag,
manuallyApprovesFollowers: user.isLocked,
- publicKey: renderKey(user, keypair),
+ publicKey: renderKey(user, keypair, `#main-key`),
isCat: user.isCat,
attachment: attachment.length ? attachment : undefined
};
diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts
index bcbb0fbe70..869fabd032 100644
--- a/src/remote/activitypub/request.ts
+++ b/src/remote/activitypub/request.ts
@@ -56,7 +56,7 @@ export default async (user: ILocalUser, url: string, object: any) => {
sign(req, {
authorizationHeaderName: 'Signature',
key: keypair.privateKey,
- keyId: `${config.url}/users/${user.id}/publickey`,
+ keyId: `${config.url}/users/${user.id}#main-key`,
headers: ['date', 'host', 'digest']
});