Amazon.in SSL Issue

This morning when I tried to shop some products on Amazon.in I received the following SSL error:-

Your connection is not private
Attackers might be trying to steal your information from amazon.in (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_COMMON_NAME_INVALID

So, I took a look at the certificate and found it to be for the domain *.cy.peg.a2z.com instead of amazon.in.

Taking a look at the certificate chain, it seems that this certificate was issued by Amazon.

The domain a2z.com is also owned by Amazon Technologies, Inc.

Which is the same as the domain Amazon.in

So, everything looks okay here.

If I manually go to the Privacy Page of Amazon.in, it is serving the correct SSL certificates:-

With a much shorter certificate chain.

I also checked the domain on SSL Shopper to make sure that this isn’t something on my end.

If I ignore the certificate error, I am able to go to the https://amazon.in page which now serves the correct certificate. Most likely, this is a deployment error and not a hack. I wonder how Amazon is serving multiple certificates for the same domain.

Update: The error is with the host amazon.in. The www version of the domain is working fine. So, use www.amazon.in to be safe.

Change the error class of asp-for in .NET Core’s MVC

This is a problem I ran into when converting my Bootstrap 3 based site to MDB which is based on Bootstrap 4.

The validation class in MDB is is-invalid as opposed to input-validation-error. I think it’s because of Bootstrap as opposed to MDB itself. But, in any case I had to change it with minimal code.

One solution is given here.

Adding the @Html.FieldHasError(m => m.Password) in the class attribute of every input seems to be too much work. So, here is my solution that uses TagHelper instead of extension methods on IHtmlHelper.

[HtmlTargetElement("input", Attributes = "md-for", TagStructure = TagStructure.WithoutEndTag)]
public class MdInputTagHelper : InputTagHelper
{
    public MdInputTagHelper(IHtmlGenerator generator)
        : base(generator)
    {
    }

    [HtmlAttributeName("md-for")]
    public ModelExpression MdFor 
    {
        get => For;
        set => For = value;
    } 

    public override void Process(TagHelperContext context, TagHelperOutput output)
    {
        base.Process(context, output);

        var fullName = NameAndIdProvider.GetFullHtmlFieldName(ViewContext, For.Name);

        if (ViewContext.ViewData.ModelState.TryGetValue(fullName, out var entry) && entry.Errors.Count > 0)
        {
            output.AddClass("is-invalid", HtmlEncoder.Default);
            output.RemoveClass("input-validation-error", HtmlEncoder.Default);
        }
    }
}

Now, to use the class invalid-feedback in your inputs you have to do a single change, replace asp-for in the input tag with md-for.

<div class="md-form">
    <i class="fas fa-envelope prefix"></i>
    <input md-for="Input.Email" class="form-control">
    <label asp-for="Input.Email">Your email</label>
    <span class="invalid-feedback" asp-validation-for="Input.Email"></span>
</div>

One last thing, remember to import the tag helper in your _ViewImports.cshtml file:-

@addTagHelper Maxotek.WebAppUtils.Helpers.MdInputTagHelper, Maxotek.WebAppUtils