beefen up the auth server public key detector
This commit is contained in:
@@ -91,6 +91,7 @@ if (IPayment._PaymentType == PaymentType.StripeIntent) {
|
|||||||
RsaSecurityKey? PublicKey = null;
|
RsaSecurityKey? PublicKey = null;
|
||||||
using (HttpClient client = new HttpClient()) {
|
using (HttpClient client = new HttpClient()) {
|
||||||
while (PublicKey == null) {
|
while (PublicKey == null) {
|
||||||
|
try {
|
||||||
HttpResponseMessage PublicKeyResponse = await client.GetAsync("https://auth.mistox.com/api/auth/publickey");
|
HttpResponseMessage PublicKeyResponse = await client.GetAsync("https://auth.mistox.com/api/auth/publickey");
|
||||||
if (PublicKeyResponse.IsSuccessStatusCode) {
|
if (PublicKeyResponse.IsSuccessStatusCode) {
|
||||||
string publicKey = await PublicKeyResponse.Content.ReadAsStringAsync();
|
string publicKey = await PublicKeyResponse.Content.ReadAsStringAsync();
|
||||||
@@ -99,8 +100,14 @@ using (HttpClient client = new HttpClient()) {
|
|||||||
PublicKey = new RsaSecurityKey(rsa);
|
PublicKey = new RsaSecurityKey(rsa);
|
||||||
} else {
|
} else {
|
||||||
await Task.Delay(2000); // sleep the main thread for 2 seconds before sending another request. Prevent DDOS of my own equiptment
|
await Task.Delay(2000); // sleep the main thread for 2 seconds before sending another request. Prevent DDOS of my own equiptment
|
||||||
|
Console.WriteLine("auth.mistox.com returned error code: " + PublicKeyResponse.StatusCode);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
await Task.Delay(2000); // sleep the main thread for 2 seconds before sending another request. Prevent DDOS of my own equiptment
|
||||||
|
Console.WriteLine("Error loading public key: " + e.InnerException?.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("PublicKey loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Services.AddAuthentication(options => {
|
builder.Services.AddAuthentication(options => {
|
||||||
|
|||||||
Reference in New Issue
Block a user