@@ -30,24 +30,20 @@ import Prelude (Show (..))
30
30
import qualified System.Process as Process
31
31
import Turtle (system )
32
32
33
- import Cardano.Shell.Configuration (ConfigurationOptions (.. ),
34
- WalletArguments (.. ),
33
+ import Cardano.Shell.Configuration (WalletArguments (.. ),
35
34
DaedalusBin (.. ))
36
35
import Cardano.Shell.Launcher.Types (LoggingDependencies (.. ))
37
36
import Cardano.Shell.Update.Lib (RemoveArchiveAfterInstall (.. ),
38
37
RunUpdateFunc , UpdaterData (.. ),
39
38
runUpdater )
40
- import Cardano.X509.Configuration (ConfigurationKey (.. ),
41
- DirConfiguration (.. ), certChecks ,
39
+ import Cardano.X509.Configuration (DirConfiguration (.. ), certChecks ,
42
40
certFilename , certOutDir ,
43
- decodeConfigFile ,
41
+ TLSConfiguration ,
44
42
fromConfiguration , genCertificate )
45
- import Control.Exception.Safe (onException )
46
43
import Data.X509.Extra (genRSA256KeyPair , validateCertificate ,
47
44
writeCertificate , writeCredentials )
48
45
import Data.X509.Validation (FailedReason )
49
- import System.Directory (createDirectoryIfMissing , doesDirectoryExist ,
50
- doesFileExist )
46
+ import System.Directory (createDirectoryIfMissing )
51
47
import System.FilePath ((</>) )
52
48
53
49
--------------------------------------------------------------------------------
@@ -297,21 +293,18 @@ runLauncher loggingDependencies walletRunner daedalusBin runUpdateFunc updaterDa
297
293
-- This just covers the generation of the TLS certificates and nothing else.
298
294
generateTlsCertificates
299
295
:: LoggingDependencies
300
- -> ConfigurationOptions
296
+ -> TLSConfiguration
301
297
-> TLSPath
302
298
-> IO (Either TLSError () )
303
- generateTlsCertificates externalDependencies' configurationOptions (TLSPath tlsPath) = runExceptT $ do
304
- doesCertConfigExist <- liftIO $ doesFileExist (cfoFilePath configurationOptions)
305
- doesTLSPathExist <- liftIO $ doesDirectoryExist tlsPath
306
- unless doesCertConfigExist $ throwError . CertConfigNotFound . cfoFilePath $ configurationOptions
307
- unless doesTLSPathExist $ throwError . TLSDirectoryNotFound $ tlsPath
299
+ generateTlsCertificates externalDependencies' tlsConfig (TLSPath tlsPath) = runExceptT $ do
308
300
309
301
let tlsServer = tlsPath </> " server"
310
302
let tlsClient = tlsPath </> " client"
311
303
312
304
-- Create the directories.
313
305
liftIO $ do
314
306
logInfo externalDependencies' $ " Generating the certificates!"
307
+ createDirectoryIfMissing True tlsPath
315
308
createDirectoryIfMissing True tlsServer
316
309
createDirectoryIfMissing True tlsClient
317
310
@@ -322,23 +315,13 @@ generateTlsCertificates externalDependencies' configurationOptions (TLSPath tlsP
322
315
-- `cardano-sl`.
323
316
generateCertificates :: FilePath -> FilePath -> ExceptT TLSError IO ()
324
317
generateCertificates tlsServer' tlsClient = do
325
-
326
- let configFile = cfoFilePath configurationOptions
327
- -- Configuration key within the config file
328
- let configKey :: ConfigurationKey
329
- configKey = ConfigurationKey . textToFilePath . cfoKey $ configurationOptions
330
-
331
318
let outDirectories :: DirConfiguration -- ^ Output directories configuration
332
319
outDirectories = DirConfiguration
333
320
{ outDirServer = tlsServer'
334
321
, outDirClients = tlsClient
335
- , outDirCA = Nothing -- TODO(KS): AFAIK, we don't output the CA.
322
+ , outDirCA = Nothing
336
323
}
337
324
338
- -- TLS configuration
339
- tlsConfig <- decodeConfigFile configKey configFile `onException`
340
- (throwError . InvalidKey . cfoKey $ configurationOptions)
341
-
342
325
-- From configuraiton
343
326
(caDesc, descs) <-
344
327
liftIO $ fromConfiguration tlsConfig outDirectories genRSA256KeyPair <$> genRSA256KeyPair
@@ -366,9 +349,6 @@ generateTlsCertificates externalDependencies' configurationOptions (TLSPath tlsP
366
349
liftIO $ do
367
350
writeCredentials (certOutDir desc </> certFilename desc) (key, cert)
368
351
writeCertificate (certOutDir desc </> caName) caCert
369
- -- Utility function.
370
- textToFilePath :: Text -> FilePath
371
- textToFilePath = strConv Strict
372
352
373
353
-- | Error that can be thrown when generating TSL certificates
374
354
data TLSError =
0 commit comments