Skip to content

Commit

Permalink
Allows CSR Port to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryFoy committed Nov 6, 2023
1 parent 4c1777c commit 050b322
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
20 changes: 10 additions & 10 deletions TAKTracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = TAKTracker/TAKTracker.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 55;
CURRENT_PROJECT_VERSION = 57;
DEVELOPMENT_ASSET_PATHS = "TAKTracker/Preview\\ Content";
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -820,7 +820,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = TAKTracker/TAKTracker.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 55;
CURRENT_PROJECT_VERSION = 57;
DEVELOPMENT_ASSET_PATHS = "TAKTracker/Preview\\ Content";
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -857,12 +857,12 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 53;
CURRENT_PROJECT_VERSION = 57;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.flighttactics.TAK-SpikeTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
Expand All @@ -879,12 +879,12 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 53;
CURRENT_PROJECT_VERSION = 57;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.flighttactics.TAK-SpikeTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
Expand All @@ -899,10 +899,10 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 53;
CURRENT_PROJECT_VERSION = 57;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.flighttactics.TAK-SpikeUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
Expand All @@ -917,10 +917,10 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 53;
CURRENT_PROJECT_VERSION = 57;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.flighttactics.TAK-SpikeUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
Expand Down
4 changes: 2 additions & 2 deletions TAKTracker/Communications/CSRRequestor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class CSRRequestor: NSObject, ObservableObject, URLSessionDelegate {
var derEncodedCertificate: [UInt8] = []
var derEncodedPrivateKey: Data = Data()

var csrPort = TAKConstants.DEFAULT_CSR_PORT
var tlsConfigPath = TAKConstants.CERT_CONFIG_PATH
var csrRequestPath = TAKConstants.certificateSigningPath(
clientUid: AppConstants.getClientID(),
Expand Down Expand Up @@ -84,6 +83,7 @@ class CSRRequestor: NSObject, ObservableObject, URLSessionDelegate {
let caConfigMethod = "GET"
let csrMethod = "POST"
let host = "https://\(SettingsStore.global.takServerUrl)"
let csrPort = SettingsStore.global.takServerCSRPort
var caConfigEntries : [String:String] = [:]
var orgNameEntry = ""
var orgUnitNameEntry = ""
Expand Down Expand Up @@ -139,7 +139,7 @@ class CSRRequestor: NSObject, ObservableObject, URLSessionDelegate {
}

// create the request
let csrURL = URL(string: "\(host):\(self.csrPort)\(self.csrRequestPath)")!
let csrURL = URL(string: "\(host):\(csrPort)\(self.csrRequestPath)")!
var csrRequest = URLRequest(url: csrURL)
csrRequest.httpMethod = csrMethod
csrRequest.setValue("text/plain; charset=utf-8", forHTTPHeaderField: "Content-Type") // the request is JSON
Expand Down
10 changes: 9 additions & 1 deletion TAKTracker/Data Models/SettingsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ class SettingsStore: ObservableObject {
}
}

@Published var takServerCSRPort: String {
didSet {
UserDefaults.standard.set(takServerPort, forKey: "takServerCSRPort")
}
}

@Published var takServerProtocol: String {
didSet {
UserDefaults.standard.set(takServerProtocol, forKey: "takServerProtocol")
Expand Down Expand Up @@ -247,7 +253,9 @@ class SettingsStore: ObservableObject {

self.takServerUrl = (UserDefaults.standard.object(forKey: "takServerUrl") == nil ? "" : UserDefaults.standard.object(forKey: "takServerUrl") as! String)

self.takServerPort = (UserDefaults.standard.object(forKey: "takServerPort") == nil ? "8089" : UserDefaults.standard.object(forKey: "takServerPort") as! String)
self.takServerPort = (UserDefaults.standard.object(forKey: "takServerPort") == nil ? TAKConstants.DEFAULT_STREAMING_PORT : UserDefaults.standard.object(forKey: "takServerPort") as! String)

self.takServerCSRPort = (UserDefaults.standard.object(forKey: "takServerCSRPort") == nil ? TAKConstants.DEFAULT_CSR_PORT : UserDefaults.standard.object(forKey: "takServerCSRPort") as! String)

self.takServerProtocol = (UserDefaults.standard.object(forKey: "takServerProtocol") == nil ? "ssl" : UserDefaults.standard.object(forKey: "takServerProtocol") as! String)

Expand Down
14 changes: 14 additions & 0 deletions TAKTracker/Screens/SettingsScreens/ConnectionOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ struct CertificateEnrollmentParameters: View {
var body: some View {
List {
ServerInformation()
Group {
VStack {
HStack {
Text("CSR Port")
.font(.system(size: 18, weight: .medium))
.foregroundColor(.secondary)
Spacer()
}
TextField("CSR Port", text: $settingsStore.takServerCSRPort)
.keyboardType(.numberPad)
}
.padding(.top, 20)
}

Group {
VStack {
HStack {
Expand Down

0 comments on commit 050b322

Please sign in to comment.