mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-04-06 11:00:08 +02:00
✨ Add certificate expiry check for sites and proxies
The lock is either locked (secured) or unlocked (unsecured). The color of this icon depends on the state: - Default appearance is OK, not expired - Orange icon means expired - Red icon means expired OR unsecured
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0.180",
|
||||||
|
"green" : "0.500",
|
||||||
|
"red" : "1.000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0.426",
|
||||||
|
"green" : "0.655",
|
||||||
|
"red" : "1.000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,14 @@ class ValetProxy: ValetListable {
|
|||||||
var target: String
|
var target: String
|
||||||
var secured: Bool = false
|
var secured: Bool = false
|
||||||
|
|
||||||
|
var certificateExpiryDate: Date?
|
||||||
|
var isCertificateExpired: Bool {
|
||||||
|
guard let certificateExpiryDate = certificateExpiryDate else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return certificateExpiryDate < Date()
|
||||||
|
}
|
||||||
|
|
||||||
var favorited: Bool = false
|
var favorited: Bool = false
|
||||||
var favoriteSignature: String {
|
var favoriteSignature: String {
|
||||||
"proxy:domain:\(domain).\(tld)|target:\(target)"
|
"proxy:domain:\(domain).\(tld)|target:\(target)"
|
||||||
@@ -79,7 +87,20 @@ class ValetProxy: ValetListable {
|
|||||||
// MARK: - Interactions
|
// MARK: - Interactions
|
||||||
|
|
||||||
func determineSecured() {
|
func determineSecured() {
|
||||||
self.secured = container.filesystem.fileExists("~/.config/valet/Certificates/\(self.domain).\(self.tld).key")
|
let certificatePath = "~/.config/valet/Certificates/\(self.domain).\(self.tld).crt"
|
||||||
|
|
||||||
|
let (exists, expiryDate) = CertificateValidator(container)
|
||||||
|
.validateCertificate(at: certificatePath)
|
||||||
|
|
||||||
|
if exists, let expiryDate {
|
||||||
|
Log.info("Certificate for \(self.domain).\(self.tld) expires at: \(expiryDate).")
|
||||||
|
} else {
|
||||||
|
Log.info("No certificate for \(self.domain).\(self.tld).")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Persist the information for the list
|
||||||
|
self.secured = exists
|
||||||
|
self.certificateExpiryDate = expiryDate
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleFavorite() {
|
func toggleFavorite() {
|
||||||
|
|||||||
@@ -39,7 +39,15 @@ class ValetSite: ValetListable {
|
|||||||
var secured: Bool!
|
var secured: Bool!
|
||||||
|
|
||||||
/// When the certificate expires.
|
/// When the certificate expires.
|
||||||
var expiryDate: Date?
|
var certificateExpiryDate: Date?
|
||||||
|
|
||||||
|
/// A simple bool to check if the certificate has expired.
|
||||||
|
var isCertificateExpired: Bool {
|
||||||
|
guard let certificateExpiryDate = certificateExpiryDate else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return certificateExpiryDate < Date()
|
||||||
|
}
|
||||||
|
|
||||||
/// What driver is currently in use. If not detected, defaults to nil.
|
/// What driver is currently in use. If not detected, defaults to nil.
|
||||||
var driver: String?
|
var driver: String?
|
||||||
@@ -141,7 +149,7 @@ class ValetSite: ValetListable {
|
|||||||
|
|
||||||
// Persist the information for the list
|
// Persist the information for the list
|
||||||
self.secured = exists
|
self.secured = exists
|
||||||
self.expiryDate = expiryDate
|
self.certificateExpiryDate = expiryDate
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,14 +17,25 @@ class DomainListTLSCell: NSTableCellView, DomainListCellProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func populateCell(with site: ValetSite) {
|
func populateCell(with site: ValetSite) {
|
||||||
|
imageViewLock.image = NSImage(named: site.secured ? "Lock" : "LockUnlocked")!
|
||||||
|
|
||||||
imageViewLock.contentTintColor = site.secured
|
imageViewLock.contentTintColor = site.secured
|
||||||
? NSColor(named: "IconColorGreen")
|
? nil
|
||||||
: NSColor(named: "IconColorRed")
|
: NSColor(named: "IconColorRed")
|
||||||
|
|
||||||
|
if site.secured && site.isCertificateExpired {
|
||||||
|
imageViewLock.contentTintColor = NSColor(named: "StatusColorOrange")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateCell(with proxy: ValetProxy) {
|
func populateCell(with proxy: ValetProxy) {
|
||||||
|
imageViewLock.image = NSImage(named: proxy.secured ? "Lock" : "LockUnlocked")!
|
||||||
imageViewLock.contentTintColor = proxy.secured
|
imageViewLock.contentTintColor = proxy.secured
|
||||||
? NSColor(named: "IconColorGreen")
|
? nil
|
||||||
: NSColor(named: "IconColorRed")
|
: NSColor(named: "IconColorRed")
|
||||||
|
|
||||||
|
if proxy.secured && proxy.isCertificateExpired {
|
||||||
|
imageViewLock.contentTintColor = NSColor(named: "StatusColorOrange")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user