text
stringlengths
0
834k
)
call %OPENSSLCMD% ca -md sha256 -out %EST_SERVER_CERT% -batch^
-config %EST_OPENSSL_CACNF%^ -extfile .\ext.cnf -infiles %EST_SERVER_CERTREQ%
if %ERRORLEVEL% neq 0 (
call :logerror ""Unable to create est server certificate"" 1
goto :script_complete
)
call %OPENSSLCMD% x509 -sha256 -in %EST_SERVER_CERT% -text
:: the mongoose https server wants to recieve the server certificate in
:: a combined file:
call :combinefiles %EST_SERVER_CERT% %EST_SERVER_PRIVKEY% %EST_SERVER_CERTANDKEY%
echo #################################################################
echo ####Creating combined trusted cert file
call :combinefiles estCA\cacert.crt extCA\cacert.crt trustedcerts.crt
echo #################################################################
echo ####Setting up and launching the estServer
:: destructive creating user of ""estuser"" w/ password ""estpwd""
:: mongoose uses the same format as apache (see htpasswd)
echo Resetting the est server password file
echo estuser:estrealm:36807fa200741bb0e8fb04fcf08e2de6 > %EST_OPENSSL_CADIR%\estpwdfile
:: merging the two ca certs into one file so that the est server can be configured
:: to use both when validating client certificates
call :combinefiles extCA\cacert.crt estCA\cacert.crt estCA\multicacerts.crt
:: Go to the end of the script
goto :script_complete
:: #############################################################################
:: Functions
:: #############################################################################
:: Return the value without its quote wrapper
:removequotes
set RETURN_VALUE=%~1
exit /b
:: Combine 2 files into 1 output file
:combinefiles
if exist %3 (
del /f /q %3
)
type %1 > %3
type %2 >> %3
exit /b
:: NOT used in createCA.sh, just ported to keep the programs in sync
:dumpheadersandcontent
echo Headers: >> %EST_LOGGING%
type %1 >> %EST_LOGGING%
echo /Headers >> %EST_LOGGING%
IF [%2] != [] (
echo Content: >> %EST_LOGGING%
if exist %2 (
type %2 >> %EST_LOGGING%
)
echo /Content >> %EST_LOGGING%
)
exit /b
:: NOT used in createCA.sh, just ported to keep the programs in sync
:: <name> header-to-search-for file-to-look-in msg-to-log additional-file-to-log
:iferrorheaderslog
findstr %1 %2 > NUL
if %ERRORLEVEL% neq 0 (
call :dumpheadersandcontent %2 %4
call :logerror ""Header ERROR: %3"" 1
)
exit /b
:: NOT used in createdCA.sh, just ported to key the programs in sync
:: TODO: support multiple certificates in pkcs7 responses (e.g. ca chains)
:: puts a (single) certificate into a degenerate pkcs7
:cert2pkcs72stdout
echo Content-Type: application/pkcs7-mime
echo.
call %OPENSSLCMD% crl2pkcs7 -certfile $1 -nocrl
exit /b
:: given a base directory name this sets up a full CA for use
:createCA
:: inputs (only 9 arguments can be passed in windows batch mode)
:: (%ARG10% is assigned before calling this function)
set CREATECA_CASUBJ=%1
set CREATECA_CADIR=%2
set CREATECA_CACERT=%3
set CREATECA_CAPRIVDIR=%4
set CREATECA_CASERIAL=%5
set CREATECA_CADATABASE=%6