-function decrypt (key, data, callback) {
- fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem', function (err, file) {
- if (err) return callback(err)
-
- const myPrivateKey = ursa.createPrivateKey(file)
- const decryptedKey = myPrivateKey.decrypt(key, 'hex', 'utf8')
- const decryptedData = symetricDecrypt(data, decryptedKey)
-
- return callback(null, decryptedData)
- })
-}
-
-function encrypt (publicKey, data, callback) {
- const crt = ursa.createPublicKey(publicKey)
-
- symetricEncrypt(data, function (err, dataEncrypted) {
- if (err) return callback(err)
-
- const key = crt.encrypt(dataEncrypted.password, 'utf8', 'hex')
- const encrypted = {
- data: dataEncrypted.crypted,
- key: key
- }
-
- callback(null, encrypted)
- })
+function getMyPrivateCert (callback) {
+ const certPath = pathUtils.join(constants.CONFIG.STORAGE.CERT_DIR, constants.PRIVATE_CERT_NAME)
+ fs.readFile(certPath, 'utf8', callback)