working #14
+11
-11
@@ -89,20 +89,20 @@ if (IPayment._PaymentType == PaymentType.StripeIntent) {
|
|||||||
|
|
||||||
RsaSecurityKey? PublicKey = null;
|
RsaSecurityKey? PublicKey = null;
|
||||||
using (HttpClient client = new HttpClient()) {
|
using (HttpClient client = new HttpClient()) {
|
||||||
HttpResponseMessage PublicKeyResponse = await client.GetAsync("https://auth.mistox.com/api/auth/publickey");
|
while (PublicKey == null) {
|
||||||
if (PublicKeyResponse.IsSuccessStatusCode) {
|
HttpResponseMessage PublicKeyResponse = await client.GetAsync("https://auth.mistox.com/api/auth/publickey");
|
||||||
string publicKey = await PublicKeyResponse.Content.ReadAsStringAsync();
|
if (PublicKeyResponse.IsSuccessStatusCode) {
|
||||||
RSA rsa = RSA.Create();
|
string publicKey = await PublicKeyResponse.Content.ReadAsStringAsync();
|
||||||
rsa.ImportFromPem(publicKey);
|
using (RSA rsa = RSA.Create()) {
|
||||||
PublicKey = new RsaSecurityKey(rsa);
|
rsa.ImportFromPem(publicKey);
|
||||||
|
PublicKey = new RsaSecurityKey(rsa);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await Task.Delay(2000); // sleep the main thread for 2 seconds before sending another request. Prevent DDOS of my own equiptment
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PublicKey == null) {
|
|
||||||
Console.WriteLine("Unable to load RSA PubKey Shutting Down");
|
|
||||||
Environment.Exit(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.Services.AddAuthentication(options => {
|
builder.Services.AddAuthentication(options => {
|
||||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
|||||||
Reference in New Issue
Block a user