generateCSR method

Future<String> generateCSR(
  1. String privateKeyPem,
  2. CSRConfigProps csrProps,
  3. String path
)

Generates a CSR (Certificate Signing Request) using the provided private key and CSR configuration properties.

Implementation

Future<String> generateCSR(
  String privateKeyPem,
  CSRConfigProps csrProps,
  String path,
) {
  /// Check if the platform is desktop (Windows, Linux, or macOS)
  bool isDeskTop = Platform.isWindows || Platform.isLinux || Platform.isMacOS;

  /// If the platform is desktop, generate the CSR using OpenSSL
  if (isDeskTop) {
    return generateCSRInDeskTop(privateKeyPem, csrProps, path);
  } else {
    /// If the platform is not desktop, throw an exception
    throw Exception(
      "CSR generation is not supported on this platform. Please use a desktop platform (Windows, Linux, or macOS) to generate the CSR.",
    );
  }
}