diff options
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) { |