Merge pull request #940 from chaotixkilla/fix-machine-token-creation
Fix pairing token creation
This commit is contained in:
commit
ee6d70d6f8
1 changed files with 4 additions and 2 deletions
|
|
@ -3,7 +3,7 @@ const pify = require('pify')
|
|||
const readFile = pify(fs.readFile)
|
||||
const crypto = require('crypto')
|
||||
const baseX = require('base-x')
|
||||
const { NIL } = require('uuid')
|
||||
const { parse, NIL } = require('uuid')
|
||||
|
||||
const options = require('../../options')
|
||||
const db = require('../../db')
|
||||
|
|
@ -16,11 +16,13 @@ const unpair = pairing.unpair
|
|||
|
||||
function totem (name) {
|
||||
const caPath = options.caPath
|
||||
const cleanNil = [...parse(NIL)].map(it => it.toString(16).padStart(2, '0')).join('')
|
||||
const nilBuffer = Buffer.from(cleanNil, 'hex')
|
||||
|
||||
return readFile(caPath)
|
||||
.then(data => {
|
||||
const caHash = crypto.createHash('sha256').update(data).digest()
|
||||
const token = Buffer.concat([crypto.randomBytes(32), NIL])
|
||||
const token = Buffer.concat([crypto.randomBytes(32), nilBuffer])
|
||||
const hexToken = token.toString('hex')
|
||||
const caHexToken = crypto.createHash('sha256').update(hexToken).digest('hex')
|
||||
const buf = Buffer.concat([caHash, token, Buffer.from(options.hostname)])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue