0
votes

We would like to connect to the SFTP server but we can't connect and NetSuite is telling us that an error occurred while decrypting credentials. Here is a snippet from our code:

var connection = sftp.createConnection({
            username: 'XXXXXXXXX',
            passwordGuid: myPwdGuid, // references var myPwdGuid
            url: 'XXX.XXX.XXX.XXX',
            port : 22,
            hostKey: myHostKey // references var myHostKey
        });

And here is the error:

{"type":"error.SuiteScriptError","name":"AN_ERROR_OCCURRED_WHILE_DECRYPT_PASSWORDGUID", "message":"資格情報の復号中にエラーが発生しました。","stack":["createError(N/error)", "main(/SuiteScripts/xxxx/xxxx/upload/uploadCsvFile.js:100)"], "cause":{"type":"internal error","code":"AN_ERROR_OCCURRED_WHILE_DECRYPT_PASSWORDGUID", "details":"資格情報の復号中にエラーが発生しました。","userEvent":null,"stackTrace":["createError(N/error)", "main(/SuiteScripts/xxxx/xxxx/upload/uploadCsvFile.js:100)"],"notifyOff":false}, "id":"","notifyOff":false,"userFacing":false}

Anything that we missed from here? Thanks!

1
How did you get the value in myPwdGuid? - bknights
My workmate seems used a Suitelet for getting the guid for this. - Aeol Cross

1 Answers

0
votes

This may help. Did you create your password GUID with an add credentials field?

Normally a suitelet is created that is used only for 'vaulting' the password. The response is a Password GUID that is stored in code or in a script parameter.

code below is Typscript:

/**
 *@NApiVersion 2.x
 *@NScriptType Suitelet
 */


import * as runtime from 'N/runtime';
import * as ui from 'N/ui/serverWidget';


export function onRequest(context) {
    if (context.request.method === 'GET') {
        var me = runtime.getCurrentScript();
        var form = ui.createForm({
            title: 'SFTP Password'
        });

        form.addCredentialField({
            id : 'username',
            label : 'Pwd',
            restrictToDomains : <string>me.getParameter({name:'custscript_ksfp_vault_host'}),
            restrictToScriptIds : ['customscript_kotn_send_sftp'],
            restrictToCurrentUser : false
        });
        form.addSubmitButton({
            label: 'Submit Button'
        });

        context.response.writePage(form);
    } else {
        var textField = context.request.parameters.username;
        context.response.write('Store this GUID in the password parameter: ' + textField);
    }
}