Skip to content

Commit

Permalink
Merge pull request #1411 from RaspAP/fix/wpa-passphrase
Browse files Browse the repository at this point in the history
Correctly handle 64 hex digit passkey
  • Loading branch information
billz authored Oct 9, 2023
2 parents c331ef9 + ff3f6dd commit 509af62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions includes/configure_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ function DisplayWPAConfig()
}
}
}
} elseif (strlen($network['passphrase']) == 0 && strlen($network['passkey']) == 64) {
$line = "\tpsk=" . $network['passkey'];
fwrite($wpa_file, "network={".PHP_EOL);
fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL);
fwrite($wpa_file, $line.PHP_EOL);
if (array_key_exists('priority', $network)) {
fwrite($wpa_file, "\tpriority=".$network['priority'].PHP_EOL);
}
fwrite($wpa_file, "}".PHP_EOL);
} else {
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
$ok = false;
Expand Down
6 changes: 3 additions & 3 deletions includes/wifi_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function knownWifiStations(&$networks)
$network['ssid'] = $ssid;
break;
case 'psk':
if (array_key_exists('passphrase', $network)) {
break;
}
$network['passkey'] = trim($lineArr[1]);
$network['protocol'] = 'WPA';
break;
case '#psk':
$network['protocol'] = 'WPA';
case 'wep_key0': // Untested
Expand Down

0 comments on commit 509af62

Please sign in to comment.