diff --git a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs index f5c9d732d6..d49e97aecb 100644 --- a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs +++ b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs @@ -778,7 +778,7 @@ public static void Write(ref Utf8JsonWriter writer, OpenIdConnectConfiguration c JsonPrimitives.WriteStrings(ref writer, Utf8Bytes.ResponseTypesSupported, config.ResponseTypesSupported); if (config.ShouldSerializeJsonWebKeys && config.JsonWebKeySet != null && config.JsonWebKeySet.Keys.Count > 0) - JsonWebKeySetSerializer.Write(ref writer, config.JsonWebKeySet, shouldWriteObject: false); + JsonWebKeySetSerializer.Append(ref writer, config.JsonWebKeySet); if (config.ScopesSupported.Count > 0) JsonPrimitives.WriteStrings(ref writer, Utf8Bytes.ScopesSupported, config.ScopesSupported); diff --git a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs index 5b1ef6f6bd..42ec2dc7bd 100644 --- a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs +++ b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs @@ -136,12 +136,15 @@ public static string Write(JsonWebKeySet jsonWebKeySet) /// /// /// - /// - public static void Write(ref Utf8JsonWriter writer, JsonWebKeySet jsonWebKeySet, bool shouldWriteObject = true) + public static void Write(ref Utf8JsonWriter writer, JsonWebKeySet jsonWebKeySet) { - if (shouldWriteObject) - writer.WriteStartObject(); + writer.WriteStartObject(); + Append(ref writer, jsonWebKeySet); + writer.WriteEndObject(); + } + internal static void Append(ref Utf8JsonWriter writer, JsonWebKeySet jsonWebKeySet) + { writer.WritePropertyName(JsonWebKeyParameterUtf8Bytes.Keys); writer.WriteStartArray(); @@ -152,9 +155,6 @@ public static void Write(ref Utf8JsonWriter writer, JsonWebKeySet jsonWebKeySet, if (jsonWebKeySet.AdditionalData.Count > 0) JsonSerializerPrimitives.WriteObjects(ref writer, jsonWebKeySet.AdditionalData); - - if (shouldWriteObject) - writer.WriteEndObject(); } #endregion