Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Jetsam Server
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jetsam
Jetsam Server
Commits
d1eabf35
Verified
Commit
d1eabf35
authored
3 years ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Add command for generating RSA keys
parent
51c433df
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
src/console/GenerateRSAPair.js
+19
-0
19 additions, 0 deletions
src/console/GenerateRSAPair.js
src/core/utils/jwt.js
+4
-2
4 additions, 2 deletions
src/core/utils/jwt.js
with
23 additions
and
2 deletions
src/console/GenerateRSAPair.js
0 → 100644
+
19
−
0
View file @
d1eabf35
module
.
exports
=
{
command
:
'
crypto:rsa:generate
'
,
description
:
'
Generate an RSA key pair, encoded as Base64
'
,
async
handler
(
args
)
{
const
{
generateRsaKeys
}
=
require
(
'
core/utils/jwt
'
)
const
{
secureHexString
,
toBase64
}
=
require
(
'
core/utils/crypto
'
)
const
key
=
await
secureHexString
(
16
)
const
{
pub
,
priv
}
=
await
generateRsaKeys
(
key
)
console
.
log
({
passphrase
:
key
,
public_key
:
toBase64
(
pub
),
private_key
:
toBase64
(
priv
),
})
process
.
exit
(
0
)
},
}
This diff is collapsed.
Click to expand it.
src/core/utils/jwt.js
+
4
−
2
View file @
d1eabf35
const
{
generateKeyPair
,
createPublicKey
,
createPrivateKey
}
=
require
(
'
crypto
'
)
async
function
generateRsaKeys
()
{
exports
.
generateRsaKeys
=
async
(
pass
=
null
)
=>
{
const
{
config
}
=
require
(
'
bootstrap
'
)
return
new
Promise
((
resolve
,
reject
)
=>
{
generateKeyPair
(
...
...
@@ -14,7 +15,7 @@ async function generateRsaKeys() {
type
:
'
pkcs8
'
,
format
:
'
pem
'
,
cipher
:
'
aes-256-cbc
'
,
passphrase
:
config
(
'
app.key
'
),
passphrase
:
pass
??
config
(
'
app.key
'
),
},
},
(
err
,
pub
,
priv
)
=>
{
...
...
@@ -27,6 +28,7 @@ async function generateRsaKeys() {
)
})
}
const
generateRsaKeys
=
exports
.
generateRsaKeys
exports
.
getKeys
=
()
=>
{
const
{
config
}
=
require
(
'
bootstrap
'
)
...
...
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