Create pub/priv keypair for federation #17071
Labels
No Label
backport/done
backport/v1.0
backport/v1.1
backport/v1.10
backport/v1.11
backport/v1.12
backport/v1.13
backport/v1.14
backport/v1.15
backport/v1.2
backport/v1.3
backport/v1.4
backport/v1.5
backport/v1.6
backport/v1.7
backport/v1.8
backport/v1.9
bounty
changelog
dependencies
frontport/done
frontport/main
good first issue
Hacktoberfest
hacktoberfest-accepted
in progress
kind/api
kind/breaking
kind/bug
kind/build
kind/deployment
kind/deprecated
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/misc
kind/moderation
kind/package
kind/proposal
kind/question
kind/refactor
kind/regression
kind/security
kind/summary
kind/testing
kind/translation
kind/ui
kind/upstream-related
kind/usability
kind/ux
lgtm/done
lgtm/need 1
lgtm/need 2
performance/bigrepo
performance/cpu
performance/memory
performance/speed
priority/critical
priority/low
priority/maybe
priority/medium
proposal/rejected
reviewed/confirmed
reviewed/duplicate
reviewed/fixed
reviewed/invalid
reviewed/not-a-bug
reviewed/wontfix
skip-changelog
stale
status/blocked
status/needs-feedback
status/wip
theme/2fa
theme/authentication
theme/avatar
theme/backup-restore
theme/docker
theme/federation
theme/issues
theme/kanban
theme/markdown
theme/migration
theme/mobile
theme/pr
theme/signing
theme/sqlite
theme/timetracker
theme/webhook
theme/wiki
No Milestone
No project
No Assignees
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: lunny/gitea#17071
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "activitypub-keypair"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
mostly Fixes #16717
skipping migration, and creating keypair for each user until other related PR is merged.
I don't think the
publicKey
function is needed as it is called only here.Additionally, the function declaration seems overly complicated to me.
If I understand go syntax correctly, the following should still be valid, right?
Is there a reason why this parameter is a generic interface and not a
rsa.PublicKey
?Because while it most likely can accept anything, the only thing I think it should accept is a
rsa.PublicKey
.Everything else is most likely a runtime error.
So, the result should most likely be
or
@ -0,0 +27,4 @@
return privPem, pubPem, nil
}
func pemBlockForPriv(priv *rsa.PrivateKey) (string, error) {
a smal simple unit test would be nice :)
@ -0,0 +27,4 @@
return privPem, pubPem, nil
}
func pemBlockForPriv(priv *rsa.PrivateKey) (string, error) {
tests have been added.
@ -0,0 +25,4 @@
assert.NotEmpty(t, pub)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN RSA PRIVATE KEY-----.*"), priv)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN PUBLIC KEY-----.*"), pub)
I think an additional statement where you encode and then decode something should be added.
This is just to show the integrity of the keys, even though I believe the crypto package already should take care of that.
@ -0,0 +25,4 @@
assert.NotEmpty(t, pub)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN RSA PRIVATE KEY-----.*"), priv)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN PUBLIC KEY-----.*"), pub)
more tests have been added
@ -0,0 +24,4 @@
assert.NotEmpty(t, priv)
assert.NotEmpty(t, pub)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN RSA PRIVATE KEY-----.*"), priv)
Can't the if be replaced by its content?
I hope
assert.NoError
checks whether an error is present itself, otherwise that function makes only limited sense.Correct me if this function categorically fails the test.
Interesting.
I expected that you would decode
msg
here to check whetherdecodedMsg == msg
.That was to show that these keys indeed work as intended.
This implementation surprises me.
I'm verifying a signature instead of encrypting data.
@ -0,0 +24,4 @@
assert.NotEmpty(t, priv)
assert.NotEmpty(t, pub)
assert.Regexp(t, regexp.MustCompile("^-----BEGIN RSA PRIVATE KEY-----.*"), priv)
Thanks, you are right that is indeed much better :)