@@ -57,12 +57,12 @@ public void ConfigureServices(IServiceCollection services)
5757 ValidAudiences = new List < string >
5858 {
5959 "http://localhost:60000" ,
60- "http ://simpleidserver.northeurope.cloudapp.azure.com/openid"
60+ "https ://simpleidserver.northeurope.cloudapp.azure.com/openid"
6161 } ,
6262 ValidIssuers = new List < string >
6363 {
6464 "http://localhost:60000" ,
65- "http ://simpleidserver.northeurope.cloudapp.azure.com/openid"
65+ "https ://simpleidserver.northeurope.cloudapp.azure.com/openid"
6666 }
6767 } ;
6868 } )
@@ -78,7 +78,7 @@ public void ConfigureServices(IServiceCollection services)
7878 ValidIssuers = new List < string >
7979 {
8080 "http://localhost:60001" ,
81- "http ://simpleidserver.northeurope.cloudapp.azure.com/oauth"
81+ "https ://simpleidserver.northeurope.cloudapp.azure.com/oauth"
8282 }
8383 } ;
8484 } ) ;
@@ -192,13 +192,35 @@ private RsaSecurityKey ExtractKey(string fileName)
192192 var rsa = RSA . Create ( ) ;
193193 var rsaParameters = new RSAParameters
194194 {
195- Modulus = Convert . FromBase64String ( dic [ "n" ] . ToString ( ) ) ,
196- Exponent = Convert . FromBase64String ( dic [ "e" ] . ToString ( ) )
195+ Modulus = Base64DecodeBytes ( dic [ "n" ] . ToString ( ) ) ,
196+ Exponent = Base64DecodeBytes ( dic [ "e" ] . ToString ( ) )
197197 } ;
198198 rsa . ImportParameters ( rsaParameters ) ;
199199 return new RsaSecurityKey ( rsa ) ;
200200 }
201201
202+ private static byte [ ] Base64DecodeBytes ( string base64EncodedData )
203+ {
204+ var s = base64EncodedData
205+ . Trim ( )
206+ . Replace ( " " , "+" )
207+ . Replace ( '-' , '+' )
208+ . Replace ( '_' , '/' ) ;
209+ switch ( s . Length % 4 )
210+ {
211+ case 0 :
212+ return Convert . FromBase64String ( s ) ;
213+ case 2 :
214+ s += "==" ;
215+ goto case 0 ;
216+ case 3 :
217+ s += "=" ;
218+ goto case 0 ;
219+ default :
220+ throw new InvalidOperationException ( "Illegal base64url string!" ) ;
221+ }
222+ }
223+
202224 private void InitializeDatabase ( IApplicationBuilder app )
203225 {
204226 var pathLst = Directory . EnumerateFiles ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "Cmmns" ) , "*.cmmn" ) . ToList ( ) ;
0 commit comments