Merge pull request #203 from roop/cleanup_cache

Cleanup cached PEMs at the end of a Session
This commit is contained in:
Davide De Rosa 2021-03-02 14:59:12 +01:00 committed by GitHub
commit 2caaae5969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -243,11 +243,7 @@ public class OpenVPNSession: Session {
/// :nodoc:
deinit {
cleanup()
let fm = FileManager.default
for url in [caURL, clientCertificateURL, clientKeyURL] {
try? fm.removeItem(at: url)
}
cleanupCache()
}
// MARK: Session
@ -358,6 +354,13 @@ public class OpenVPNSession: Session {
stopError = nil
}
func cleanupCache() {
let fm = FileManager.default
for url in [caURL, clientCertificateURL, clientKeyURL] {
try? fm.removeItem(at: url)
}
}
// MARK: Loop
// Ruby: start
@ -1249,6 +1252,7 @@ public class OpenVPNSession: Session {
switch method {
case .shutdown:
self?.doShutdown(error: error)
self?.cleanupCache()
case .reconnect:
self?.doReconnect(error: error)