diff --git a/CMakeLists.txt b/CMakeLists.txt index ea45ddfd5..bde77e485 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,8 +178,6 @@ file(COPY ${CMAKE_SOURCE_DIR}/dev.conf DESTINATION ${CMAKE_BINARY_DIR}/config) file(COPY ${CMAKE_SOURCE_DIR}/neuron.json DESTINATION ${CMAKE_BINARY_DIR}/config) file(COPY ${CMAKE_SOURCE_DIR}/.gitkeep DESTINATION ${CMAKE_BINARY_DIR}/logs) file(COPY ${CMAKE_SOURCE_DIR}/.gitkeep DESTINATION ${CMAKE_BINARY_DIR}/persistence) -file(COPY ${CMAKE_SOURCE_DIR}/neuron.key DESTINATION ${CMAKE_BINARY_DIR}/config) -file(COPY ${CMAKE_SOURCE_DIR}/neuron.pem DESTINATION ${CMAKE_BINARY_DIR}/config) file(GLOB SQL_SCHEMAS ${CMAKE_SOURCE_DIR}/persistence/*.sql) file(COPY ${SQL_SCHEMAS} DESTINATION ${CMAKE_BINARY_DIR}/config) file(COPY ${CMAKE_SOURCE_DIR}/default_plugins.json DESTINATION ${CMAKE_BINARY_DIR}/config) diff --git a/package-sdk.sh b/package-sdk.sh index a6262b012..44332e7a6 100755 --- a/package-sdk.sh +++ b/package-sdk.sh @@ -51,8 +51,6 @@ cp persistence/*.sql ${package_name}/config/ cp sdk-zlog.conf ${package_name}/config/ cp zlog.conf ${package_name}/config/ cp dev.conf ${package_name}/config/ -cp neuron.key ${package_name}/config/ -cp neuron.pem ${package_name}/config/ cp default_plugins.json ${package_name}/config/ cp neuron.json ${package_name}/config/ diff --git a/sdk-install.sh b/sdk-install.sh index 65991690f..0a835f86f 100755 --- a/sdk-install.sh +++ b/sdk-install.sh @@ -25,8 +25,6 @@ mkdir -p ${neuron_bin}/plugins cp ./neuron ${neuron_bin}/ cp config/sdk-zlog.conf ${neuron_bin}/config/zlog.conf cp config/dev.conf ${neuron_bin}/config/ -cp config/neuron.key ${neuron_bin}/config/ -cp config/neuron.pem ${neuron_bin}/config/ cp config/default_plugins.json ${neuron_bin}/config/ cp config/*.sql ${neuron_bin}/config/ diff --git a/src/utils/neu_jwt.c b/src/utils/neu_jwt.c index a688489ee..b180916cb 100644 --- a/src/utils/neu_jwt.c +++ b/src/utils/neu_jwt.c @@ -43,6 +43,46 @@ static struct public_key_store key_store; static char neuron_private_key[2048] = { 0 }; static char neuron_public_key[2048] = { 0 }; +static const char *private_key_content = + "-----BEGIN RSA PRIVATE KEY-----\n" + "MIIEpAIBAAKCAQEAzrO7FUz4GGKl4nP5lwKMh5uageJAAHnLZpVxTR1wXA9E870s\n" + "U03gHnPWsh2bXCCx85ymYaiu/5VlptgnU0rQB1I3xGRG8eHmHPrhHNWDRKpY6oY8\n" + "AnTPqXvfa/Z4u+njJzDSqi4qM8Gwfqlgpjlg8DUF+sheLx8hL+x9XFzovTxafrmy\n" + "JRRAVQTkhB7esKKqRF8BMjdOdYZxJEv9jxa0BwXcjprPDlj5TV6k3wJqbq4UtnEE\n" + "VbjEQKqFVkfY4FuJ5NSPHpGEix94PGQGRsiWkGX0vx5udHJ0SlXM6qpMLny18FhW\n" + "bwKNX3urc3mImn/j3zcJ5x1d+FlXAXs1NBSeTQIDAQABAoIBAQDJOT8PZXbAhohn\n" + "A/AeimS0P08S0mbsD6VroGBEajxP4q2FeswD7PQZsTt4+kmcTlfuiLmQqN50AcSL\n" + "wDHIbDRIbEnN7rECGKAj5jfwEgtQdWVKKpOQ8JaYr/a466BtjyuLo4PyGC8NY6mm\n" + "JM3qBEHSlkvT7+uAhBWSye7gU7JfRPoCeFRpaMMC3Ad0DaIt/Pdt9CddNwj56+9j\n" + "gl//blNnBImjvA7/kh9gL69SYVrQoG9vm/UgFbdIwd+w2hhhpx6kuHjRJ21xIV/y\n" + "Yh9k4QhPr7zIkhQ8yn11ZhyZkMC8XAMy7NKCmAFIPNJ8jwvgBkunPEk2aYBeDUaq\n" + "a30VwlIhAoGBAOnm8DW5DROcfSj4Q8zsvgmvhGM0zzF5zmA+4E+tEbf4t6sDUjSs\n" + "ADo2EaiJZz75vLsD7UZHKzFEV/wnuT7SiNCbrJafx8Tp2UgijTkW8gEhAWREJDn5\n" + "FS375RKFdEcpmVHWgsuz4z/0L3BGxmyYWQxx5pD2NL49ZpTIHAHm/XETAoGBAOI6\n" + "8Y08TmM2bnXbL/MggYMJlqOyv27ueVYz9of3FYFAMIe7ebSgrlSCOwsoDZYmegBM\n" + "OrowR3AAnoP4fjGNbIPjNYbiv1qLOdtnvPxYotEz+ZaUBSn9V/gUEVFlgrKxgTKr\n" + "sqi/QMyyJplBTUkUuqYRDuv6TZ3OWKiDUoXTdv8fAoGBAIbbyf+PlESMY3Vtvtm2\n" + "XdODyRbR6ewiyKShW/9UT/T8iBknrwwDZ5YoeoHrxwV+RBynpPRyMCsVto0B8kKQ\n" + "bKWqPBYURb/4/Hgkw7v4yMtx1jWTPDfYryd2JptJKsOk7mtK/Nqp+wpypa9cfyc5\n" + "p44PVdqauco96Jk7zzohjlrVAoGAfjQDrJaH5DDpTjYIeckYdtFSh9+fi3LdnYk/\n" + "bnoYNRJqAE5Fhs5ccih0Z7TgX3L3fFMKL/Pe5kxyIYzuWRZcAvctVSIJPamNjShB\n" + "9UQ9EBe+lJHej54VBP+s6YuHbcg4GtxNvnVy4L5Bah1T0AEQXrQFbv8jbXU/YEJi\n" + "NuXQ7GECgYA0UNvuZxVSDn8fBxARcX3ub5aok5owdLL3SOCPMpNrmOBQj8iJGT+5\n" + "nv7fH1TWVh9yUdRwhd81s5H/PO3/myLmgq0TcPvewtEEwY+++QpsYZwHTDXgxbbw\n" + "++lmJali4fzmd/72JqocGABYhZFt0jbcQ1QEcqUYcD380+cNVZPO+w==\n" + "-----END RSA PRIVATE KEY-----\n"; + +const char *public_key_content = + "-----BEGIN PUBLIC KEY-----\n" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzrO7FUz4GGKl4nP5lwKM\n" + "h5uageJAAHnLZpVxTR1wXA9E870sU03gHnPWsh2bXCCx85ymYaiu/5VlptgnU0rQ\n" + "B1I3xGRG8eHmHPrhHNWDRKpY6oY8AnTPqXvfa/Z4u+njJzDSqi4qM8Gwfqlgpjlg\n" + "8DUF+sheLx8hL+x9XFzovTxafrmyJRRAVQTkhB7esKKqRF8BMjdOdYZxJEv9jxa0\n" + "BwXcjprPDlj5TV6k3wJqbq4UtnEEVbjEQKqFVkfY4FuJ5NSPHpGEix94PGQGRsiW\n" + "kGX0vx5udHJ0SlXM6qpMLny18FhWbwKNX3urc3mImn/j3zcJ5x1d+FlXAXs1NBSe\n" + "TQIDAQAB\n" + "-----END PUBLIC KEY-----\n"; + static int find_key(const char *name) { for (int i = 0; i < key_store.size; i++) { @@ -95,15 +135,13 @@ static char *load_key(const char *dir, char *name) static void load_neuron_key(const char *dir_path) { - char *content = load_key(dir_path, "neuron.key"); - assert(content != NULL); - - strncpy(neuron_private_key, content, sizeof(neuron_private_key) - 1); - content = load_key(dir_path, "neuron.pem"); - assert(content != NULL); + (void) dir_path; + strncpy(neuron_private_key, private_key_content, + sizeof(neuron_private_key) - 1); - strncpy(neuron_public_key, content, sizeof(neuron_public_key) - 1); + strncpy(neuron_public_key, public_key_content, + sizeof(neuron_public_key) - 1); } static void scanf_key(const char *dir_path) diff --git a/tests/ft/persist/test_persist.py b/tests/ft/persist/test_persist.py index 2cb1a74f1..81808a504 100644 --- a/tests/ft/persist/test_persist.py +++ b/tests/ft/persist/test_persist.py @@ -463,19 +463,12 @@ def test_unsubscribe_and_restart(self): @description(given="upload pem in certs", when="login", then="success") def test_jwt(self): - if not os.path.exists('./build/certs/'): - os.makedirs('./build/certs/') - - shutil.copyfile('./build/config/neuron.pem', './build/certs/neuron.pem') - p = process.NeuronProcess() p.start() response = api.login() assert 200 == response.status_code - shutil.rmtree('./build/certs/') - p.stop() @description(given="new schema", when="upload schema , restart and add tags", then="success") diff --git a/tests/ut/CMakeLists.txt b/tests/ut/CMakeLists.txt index 09b9323ab..4c73760cd 100644 --- a/tests/ut/CMakeLists.txt +++ b/tests/ut/CMakeLists.txt @@ -19,8 +19,6 @@ target_include_directories(http_test PRIVATE ${CMAKE_SOURCE_DIR}/plugins/restful) target_link_libraries(http_test neuron-base gtest_main gtest jansson nng) -file(COPY ${CMAKE_SOURCE_DIR}/neuron.key DESTINATION ${UT_DIRECTORY}/config) -file(COPY ${CMAKE_SOURCE_DIR}/neuron.pem DESTINATION ${UT_DIRECTORY}/config) add_executable(jwt_test jwt_test.cc) target_include_directories(jwt_test PRIVATE ${CMAKE_SOURCE_DIR}/src