Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andy Craze
funkwhale
Commits
f4f44c34
Verified
Commit
f4f44c34
authored
5 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
See #170: switch to PKCS#8 for public key serialization
parent
24405505
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/federation/keys.py
+2
-1
2 additions, 1 deletion
api/funkwhale_api/federation/keys.py
api/funkwhale_api/federation/migrations/0026_public_key_format.py
+56
-0
56 additions, 0 deletions
...whale_api/federation/migrations/0026_public_key_format.py
with
58 additions
and
1 deletion
api/funkwhale_api/federation/keys.py
+
2
−
1
View file @
f4f44c34
...
@@ -21,7 +21,8 @@ def get_key_pair(size=None):
...
@@ -21,7 +21,8 @@ def get_key_pair(size=None):
crypto_serialization
.
NoEncryption
(),
crypto_serialization
.
NoEncryption
(),
)
)
public_key
=
key
.
public_key
().
public_bytes
(
public_key
=
key
.
public_key
().
public_bytes
(
crypto_serialization
.
Encoding
.
PEM
,
crypto_serialization
.
PublicFormat
.
PKCS1
crypto_serialization
.
Encoding
.
PEM
,
crypto_serialization
.
PublicFormat
.
SubjectPublicKeyInfo
,
)
)
return
private_key
,
public_key
return
private_key
,
public_key
...
...
This diff is collapsed.
Click to expand it.
api/funkwhale_api/federation/migrations/0026_public_key_format.py
0 → 100644
+
56
−
0
View file @
f4f44c34
# Generated by Django 2.0.9 on 2018-11-14 08:55
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
django.utils.timezone
def
update_public_key_format
(
apps
,
schema_editor
):
"""
Reserialize keys in proper format (PKCS#8 instead of #1)
https://github.com/friendica/friendica/issues/7771#issuecomment-603019826
"""
Actor
=
apps
.
get_model
(
"
federation
"
,
"
Actor
"
)
local_actors
=
list
(
Actor
.
objects
.
exclude
(
private_key
=
""
)
.
exclude
(
private_key
=
None
)
.
only
(
"
pk
"
,
"
private_key
"
,
"
public_key
"
)
.
order_by
(
"
id
"
)
)
total
=
len
(
local_actors
)
if
total
:
print
(
"
{} keys to update...
"
.
format
(
total
))
else
:
print
(
"
Skipping
"
)
return
from
cryptography.hazmat.primitives
import
serialization
as
crypto_serialization
from
cryptography.hazmat.backends
import
default_backend
for
actor
in
local_actors
:
private_key
=
crypto_serialization
.
load_pem_private_key
(
actor
.
private_key
.
encode
(),
password
=
None
,
backend
=
default_backend
()
)
public_key
=
private_key
.
public_key
().
public_bytes
(
crypto_serialization
.
Encoding
.
PEM
,
crypto_serialization
.
PublicFormat
.
SubjectPublicKeyInfo
,
)
actor
.
public_key
=
public_key
.
decode
()
Actor
.
objects
.
bulk_update
(
local_actors
,
[
"
public_key
"
])
print
(
"
Done!
"
)
def
skip
(
apps
,
schema_editor
):
pass
class
Migration
(
migrations
.
Migration
):
dependencies
=
[(
"
federation
"
,
"
0025_auto_20200317_0820
"
)]
operations
=
[
migrations
.
RunPython
(
update_public_key_format
,
skip
),
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment