diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-07 16:57:28 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-07 18:23:18 +0200 |
commit | 709756b8e183f67ef9bf8f7bc149af4736260350 (patch) | |
tree | dc5e52878a6f56c69a4589e058e830c57b025a05 /server/helpers/peertube-crypto.ts | |
parent | 18c8e945089bff49d2c617c411c8a8f4575989ad (diff) | |
download | PeerTube-709756b8e183f67ef9bf8f7bc149af4736260350.tar.gz PeerTube-709756b8e183f67ef9bf8f7bc149af4736260350.tar.zst PeerTube-709756b8e183f67ef9bf8f7bc149af4736260350.zip |
Async signature and various fixes
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r-- | server/helpers/peertube-crypto.ts | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index 8e8001cd6..0c73e8539 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as crypto from 'crypto' | 1 | import * as crypto from 'crypto' |
2 | import * as fs from 'fs' | 2 | import * as Promise from 'bluebird' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | 4 | ||
5 | import { | 5 | import { |
@@ -52,18 +52,15 @@ function sign (data: string|Object) { | |||
52 | dataString = JSON.stringify(data) | 52 | dataString = JSON.stringify(data) |
53 | } catch (err) { | 53 | } catch (err) { |
54 | logger.error('Cannot sign data.', { error: err }) | 54 | logger.error('Cannot sign data.', { error: err }) |
55 | return '' | 55 | return Promise.resolve('') |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | sign.update(dataString, 'utf8') | 59 | sign.update(dataString, 'utf8') |
60 | 60 | ||
61 | // TODO: make async | 61 | return getMyPrivateCert().then(myKey => { |
62 | const certPath = join(CONFIG.STORAGE.CERT_DIR, PRIVATE_CERT_NAME) | 62 | return sign.sign(myKey, SIGNATURE_ENCODING) |
63 | const myKey = fs.readFileSync(certPath) | 63 | }) |
64 | const signature = sign.sign(myKey.toString(), SIGNATURE_ENCODING) | ||
65 | |||
66 | return signature | ||
67 | } | 64 | } |
68 | 65 | ||
69 | function comparePassword (plainPassword: string, hashPassword: string) { | 66 | function comparePassword (plainPassword: string, hashPassword: string) { |