aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/peertube-crypto.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r--server/helpers/peertube-crypto.ts13
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 @@
1import * as crypto from 'crypto' 1import * as crypto from 'crypto'
2import * as fs from 'fs' 2import * as Promise from 'bluebird'
3import { join } from 'path' 3import { join } from 'path'
4 4
5import { 5import {
@@ -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
69function comparePassword (plainPassword: string, hashPassword: string) { 66function comparePassword (plainPassword: string, hashPassword: string) {