From e080fe9976b2be1f9b10785ece886ef24a1315d5 Mon Sep 17 00:00:00 2001 From: Sergiy Lavrynenko Date: Mon, 3 Jul 2023 11:53:03 +0100 Subject: [PATCH] Fixed issue - SGX url is unknown during - in PWA subsystem --- agent/bls.mjs | 2 +- agent/cli.mjs | 65 +++++++++++++++++++++++++++++++++++++++++++++++---- agent/run.sh | 8 +++---- 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/agent/bls.mjs b/agent/bls.mjs index 0feaa2174..fa0f7059e 100644 --- a/agent/bls.mjs +++ b/agent/bls.mjs @@ -2800,7 +2800,7 @@ export async function handleSkaleImaVerifyAndSign( joCallData ) { if( ! joAccount.strURL ) { joAccount = optsHandleVerifyAndSign.imaState.chainProperties.mn.joAccount; if( ! joAccount.strSgxURL ) - throw new Error( "SGX URL is unknown, cannot sign IMA message(s)" ); + throw new Error( "SGX URL is unknown, cannot sign(handle) IMA message(s)" ); if( ! joAccount.strBlsKeyName ) throw new Error( "BLS keys name is unknown, cannot sign IMA message(s)" ); } diff --git a/agent/cli.mjs b/agent/cli.mjs index 39fad73f6..12058a7ff 100644 --- a/agent/cli.mjs +++ b/agent/cli.mjs @@ -475,10 +475,11 @@ function printHelpUserAccount1( soi ) { console.log( soi + cc.debug( "--" ) + cc.bright( "sgx-url-t-chain" ) + cc.sunny( "=" ) + cc.attention( "URL" ) + cc.debug( "..................." ) + cc.sunny( "SGX server" ) + - cc.notice( " URL for " ) + cc.note( "S<->S Target S-chain" ) + - cc.notice( ". Value is automatically loaded from the " ) + - cc.warning( "SGX_URL_S_CHAIN_TARGET" ) + - cc.notice( " environment variable if not specified." ) ); + cc.notice( " URL for " ) + cc.note( "S<->S Target S-chain." ) ); + console.log( soi + cc.debug( "--" ) + + cc.bright( "sgx-url" ) + cc.sunny( "=" ) + cc.attention( "URL" ) + + cc.debug( "..................." ) + cc.sunny( "SGX server" ) + + cc.notice( " URL for all chains." ) ); console.log( soi + cc.debug( "--" ) + cc.bright( "sgx-ecdsa-key-main-net" ) + cc.sunny( "=" ) + cc.error( "name" ) + cc.debug( "..........." ) + cc.attention( "SGX/ECDSA key name" ) + @@ -500,6 +501,10 @@ function printHelpUserAccount1( soi ) { cc.notice( ". Value is automatically loaded from the " ) + cc.warning( "SGX_KEY_S_CHAIN_TARGET" ) + cc.notice( " environment variable if not specified." ) ); + console.log( soi + cc.debug( "--" ) + + cc.bright( "sgx-ecdsa-key" ) + cc.sunny( "=" ) + cc.error( "name" ) + + cc.debug( "............" ) + cc.attention( "SGX/ECDSA key name" ) + + cc.notice( " for all chains." ) ); console.log( soi + cc.debug( "--" ) + cc.bright( "sgx-bls-key-main-net" ) + cc.sunny( "=" ) + cc.error( "name" ) + cc.debug( "............." ) + cc.attention( "SGX/BLS key name" ) + @@ -521,6 +526,10 @@ function printHelpUserAccount1( soi ) { cc.notice( ". Value is automatically loaded from the " ) + cc.warning( "BLS_KEY_S_CHAIN_TARGET" ) + cc.notice( " environment variable if not specified." ) ); + console.log( soi + cc.debug( "--" ) + + cc.bright( "sgx-bls-key" ) + cc.sunny( "=" ) + cc.error( "name" ) + + cc.debug( ".............." ) + cc.attention( "SGX/BLS key name" ) + + cc.notice( " for all chains." ) ); console.log( soi + cc.debug( "--" ) + cc.bright( "sgx-ssl-key-main-net" ) + cc.sunny( "=" ) + cc.attention( "path" ) + cc.debug( "............." ) + cc.notice( "Path to " ) + cc.note( "SSL key file" ) + @@ -544,6 +553,10 @@ function printHelpUserAccount1( soi ) { cc.notice( ". Value is automatically loaded from the " ) + cc.warning( "SGX_SSL_KEY_FILE_S_CHAIN_TARGET" ) + cc.notice( " environment variable if not specified." ) ); + console.log( soi + cc.debug( "--" ) + + cc.bright( "sgx-ssl-key" ) + cc.sunny( "=" ) + cc.attention( "path" ) + + cc.debug( ".............." ) + cc.notice( "Path to " ) + cc.note( "SSL key file" ) + + cc.notice( " for " ) + cc.bright( "SGX wallet" ) + cc.notice( " of all chains." ) ); console.log( soi + cc.debug( "--" ) + cc.bright( "sgx-ssl-cert-main-net" ) + cc.sunny( "=" ) + cc.attention( "path" ) + cc.debug( "............" ) + cc.notice( "Path to " ) + @@ -569,6 +582,10 @@ function printHelpUserAccount1( soi ) { cc.notice( ". Value is automatically loaded from the " ) + cc.warning( "SGX_SSL_CERT_FILE_S_CHAIN_TARGET" ) + cc.notice( " environment variable if not specified." ) ); + console.log( soi + cc.debug( "--" ) + + cc.bright( "sgx-ssl-cert" ) + cc.sunny( "=" ) + cc.attention( "path" ) + + cc.debug( "............." ) + cc.notice( "Path to " ) + + cc.note( "SSL certificate file" ) + cc.notice( " for all chains." ) ); console.log( soi + cc.debug( "--" ) + cc.bright( "address-main-net" ) + cc.sunny( "=" ) + cc.warning( "value" ) + cc.debug( "................" ) + cc.note( "Main-net" ) + " " + @@ -1570,6 +1587,14 @@ function parseSgxArgs( imaState, joArg ) { imaState.chainProperties.tc.joAccount.strSgxURL = joArg.value; return true; } + if( joArg.name == "sgx-url" ) { + owaspUtils.verifyArgumentIsURL( joArg ); + imaState.chainProperties.mn.joAccount.strSgxURL = + imaState.chainProperties.sc.joAccount.strSgxURL = + imaState.chainProperties.tc.joAccount.strSgxURL = + joArg.value; + return true; + } if( joArg.name == "sgx-ecdsa-key-main-net" ) { owaspUtils.verifyArgumentWithNonEmptyValue( joArg ); imaState.chainProperties.mn.joAccount.strSgxKeyName = joArg.value; @@ -1585,6 +1610,14 @@ function parseSgxArgs( imaState, joArg ) { imaState.chainProperties.tc.joAccount.strSgxKeyName = joArg.value; return true; } + if( joArg.name == "sgx-ecdsa-key" ) { + owaspUtils.verifyArgumentWithNonEmptyValue( joArg ); + imaState.chainProperties.mn.joAccount.strSgxKeyName = + imaState.chainProperties.sc.joAccount.strSgxKeyName = + imaState.chainProperties.tc.joAccount.strSgxKeyName = + joArg.value; + return true; + } if( joArg.name == "sgx-bls-key-main-net" ) { owaspUtils.verifyArgumentWithNonEmptyValue( joArg ); imaState.chainProperties.mn.joAccount.strBlsKeyName = joArg.value; @@ -1600,6 +1633,14 @@ function parseSgxArgs( imaState, joArg ) { imaState.chainProperties.tc.joAccount.strBlsKeyName = joArg.value; return true; } + if( joArg.name == "sgx-bls-key" ) { + owaspUtils.verifyArgumentWithNonEmptyValue( joArg ); + imaState.chainProperties.mn.joAccount.strBlsKeyName = + imaState.chainProperties.sc.joAccount.strBlsKeyName = + imaState.chainProperties.tc.joAccount.strBlsKeyName = + joArg.value; + return true; + } if( joArg.name == "sgx-ssl-key-main-net" ) { owaspUtils.verifyArgumentIsPathToExistingFile( joArg ); imaState.chainProperties.mn.joAccount.strPathSslKey = @@ -1618,6 +1659,14 @@ function parseSgxArgs( imaState, joArg ) { imaUtils.normalizePath( joArg.value ); return true; } + if( joArg.name == "sgx-ssl-key" ) { + owaspUtils.verifyArgumentIsPathToExistingFile( joArg ); + imaState.chainProperties.mn.joAccount.strPathSslKey = + imaState.chainProperties.sc.joAccount.strPathSslKey = + imaState.chainProperties.tc.joAccount.strPathSslKey = + imaUtils.normalizePath( joArg.value ); + return true; + } if( joArg.name == "sgx-ssl-cert-main-net" ) { owaspUtils.verifyArgumentIsPathToExistingFile( joArg ); imaState.chainProperties.mn.joAccount.strPathSslCert = @@ -1636,6 +1685,14 @@ function parseSgxArgs( imaState, joArg ) { imaUtils.normalizePath( joArg.value ); return true; } + if( joArg.name == "sgx-ssl-cert" ) { + owaspUtils.verifyArgumentIsPathToExistingFile( joArg ); + imaState.chainProperties.mn.joAccount.strPathSslCert = + imaState.chainProperties.sc.joAccount.strPathSslCert = + imaState.chainProperties.tc.joAccount.strPathSslCert = + imaUtils.normalizePath( joArg.value ); + return true; + } return false; } diff --git a/agent/run.sh b/agent/run.sh index 39e0a1469..9845fd9c5 100644 --- a/agent/run.sh +++ b/agent/run.sh @@ -80,10 +80,10 @@ BASE_OPTIONS="--gas-price-multiplier=$GAS_PRICE_MULTIPLIER \ --cid-s-chain=$CID_SCHAIN \ --abi-main-net=$MAINNET_PROXY_PATH \ --abi-s-chain=$SCHAIN_PROXY_PATH \ ---sgx-url-s-chain=$SGX_URL \ ---sgx-ecdsa-key-s-chain=$ECDSA_KEY_NAME \ ---sgx-ssl-key-s-chain=$SGX_SSL_KEY_PATH \ ---sgx-ssl-cert-s-chain=$SGX_SSL_CERT_PATH \ +--sgx-url=$SGX_URL \ +--sgx-ecdsa-key=$ECDSA_KEY_NAME \ +--sgx-ssl-key=$SGX_SSL_KEY_PATH \ +--sgx-ssl-cert=$SGX_SSL_CERT_PATH \ --address-main-net=$NODE_ADDRESS \ --address-s-chain=$NODE_ADDRESS \ --sign-messages \