text
stringlengths
0
834k
set EST_SERVER_CCAUTHZDB=ccAuthz.db
:: TODO: check to see if cmd path's have been overridden by a local settings file
:: which openssl to use (Not depending on the path because openssl has many
:: versions with various functionalities. Many OS distributions have an
:: older version. These scripts were intially tested against OpenSSL 0.9.8r
::set OPENSSLCMD=~/src/openssl-fecc2/apps/openssl
::set OPENSSLCMD=~/src/openssl-1.0.1c/apps/openssl
set OPENSSLCMD=openssl
:: which version of curl to use (also not depending on the path)
set CURLCMD=curl
:: demoClient variables
set EST_DEMOCLIENT_DIR=demoClient
set EST_DEMOCLIENT_CACERT=%EST_DEMOCLIENT_DIR%\cacert.pem
set EST_DEMOCLIENT_CACERTUPDATED=%EST_DEMOCLIENT_DIR%\cacert_updated.pem
:: ############################################################################
:: createCA.sh port (createCA function is in the Function section below)
:: ############################################################################
:: completely clean out and re-create demoCA database directories (DESTRUCTIVE!!)
echo #################################################################
echo SECURITY CONSIDERATIONS - NOTE WELL
echo The sample scripts used to handle EST operations are NOT
echo intended to provide a secure implementation. They have not
echo been evaluated for security, they have not had a Thread Model
echo reviewed, they are not particularly good about cleaning up after
echo themselves and they assume the data exchanged is well formed
echo if the cryptographic checks pass.
echo.
echo In short: They are not to be trusted. They provide a functional
echo implementation only.
echo.
echo Continuing will completely erase/destroy/nuke the existing estCA
set /p DUMMY=""Press return...""
echo.
echo Nuking from orbit!
echo #################################################################
rmdir /s /q %EST_OPENSSL_CADIR%
rmdir /s /q %EST_OPENSSL_EXTCADIR%
:: Create a 3rd party (existing) CA certificate
:: Think of this like a common web CA as one might purchase certificates from
echo #################################################################
echo ####(Re)creating an initial EXTERNAL 'web root CA' certificate
echo #################################################################
:: Batch scripts only allow 9 arguments to be passed in, manually setup #10
set ARG10=%EST_OPENSSLCMD_EXTCAECPARAMSFILE%
call :createCA %EST_OPENSSL_EXTCASUBJ%^
%EST_OPENSSL_EXTCADIR%^
%EST_OPENSSL_EXTCACERT%^
%EST_OPENSSL_EXTCAPRIVDIR%^
%EST_OPENSSL_EXTCASERIAL%^
%EST_OPENSSL_EXTCADATABASE%^
%EST_OPENSSL_EXTCANEWCERTSDIR%^
%EST_OPENSSL_EXTCAPRIVKEY%^
%EST_OPENSSLCMD_EXTCANEWKEY_PARAM%
if %RETURN_CODE% neq 0 (
goto :script_complete
)
:: Create our CA certificate
echo #################################################################
echo ####(Re)creating an initial root CA certificate
echo #################################################################
:: Batch scripts only allow 9 arguments to be passed in, manually setup #10
set ARG10=%EST_OPENSSLCMD_CAECPARAMSFILE%
call :createCA %EST_OPENSSL_CASUBJ%^
%EST_OPENSSL_CADIR%^
%EST_OPENSSL_CACERT%^
%EST_OPENSSL_CAPRIVDIR%^
%EST_OPENSSL_CASERIAL%^
%EST_OPENSSL_CADATABASE%^
%EST_OPENSSL_CANEWCERTSDIR%^
%EST_OPENSSL_CAPRIVKEY%^
%EST_OPENSSLCMD_CANEWKEY_PARAM%
if %RETURN_CODE% neq 0 (
goto :script_complete
)
:: Create a certificate for our est server
:: TODO: add extension for est server
echo #################################################################
echo ####(Re)creating an initial peer certificate for our estServer to use
echo #################################################################
:: re-using the same NEWKEY_PARAM as is used for our CA
call :removequotes %EST_OPENSSLCMD_CANEWKEY_PARAM%
set EST_OPENSSLCMD_CANEWKEY_PARAM=%RETURN_VALUE%
call %OPENSSLCMD% req -new -sha256 -nodes -out %EST_SERVER_CERTREQ%^
%EST_OPENSSLCMD_CANEWKEY_PARAM% -keyout %EST_SERVER_PRIVKEY%^
-subj %EST_SERVER_SUBJ% -config %EST_OPENSSL_CACNF%
if %ERRORLEVEL% neq 0 (
call :logerror ""Unable to create est server CSR"" 1
goto :script_complete