Skip to content

Category: Coding

tls: failed to verify certificate: x509: certificate signed by unknown authority

In building a docker image for a Go application using the Apline image, I kept getting this error “tls: failed to verify certificate: x509: certificate signed by unknown authority”. I thought it was something with the code I was writing, but it had to do with the docker image.

Adding this to your Dockerfile should fix the problem. The problem is that the docker container doesn’t have the necessary certs to validate the connection. You might also get around this issue by adding the “ca-certificates” package to the image, but I didn’t try that.

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

or (depends on how your building your image)

COPY /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
Leave a Comment

Install dotnet core on Ubuntu 22.04

These are the steps I used to install dotnet core on Ubuntu 22.04, both the SDK and the runtime.

apt update
apt install -y apt-transport-https
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt update
apt install -y dotnet-sdk-7.0
apt update
apt install -y aspnetcore-runtime-7.0

To verify installation run the following commands. If the below doesn’t work try to open a new ssh session or terminal.

dotnet --list-runtimes

Microsoft.AspNetCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

dotnet --list-sdks

7.0.102 [/usr/share/dotnet/sdk]
root@srv4311:~# 

If you tried previously to install version 7.0 make sure you remove/purge the old version from the system. Something like below.

apt remove --purge dotnet-sdk-6.0 dotnet-runtime-6.0
apt auto-remove

Also maybe delete the .dotnet folder in your home directory.

Leave a Comment

Finally, put a Spanish wordlist together.

I could finally put a Spanish wordlist together to tie it in with my Wordle Spanish app because the original dictionary I had was not very good and I was getting complaints about some words being used. It was true. I found some words in the original wordlist that were not even Spanish.

So here is the new list that was created with some help from other repos.

https://github.com/xavier-hernandez/spanish-wordlist

Leave a Comment

Getting error An unhandled exception has occurred. See browser dev tools for details.

I deleted all the CSS from site.css and replaced it with mine of course but after that, I started receiving the following error “Getting error An unhandled exception has occurred. See browser dev tools for details. Reload”. It looks like this occurs because blazor needs at least 2 styles to display errors.

Found my answer here.

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

Leave a Comment

PayPal Test Credit Card Numbers

Because I keep losing this content and old pages are coming up with 404s.

More information can be found here: https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/pp_payflowpro_guide.pdf

AmountResult
$0 – $1000

RESULT value 0 (Approved)
$1001 – $2000Certain amounts in this range will return specific PayPal results and can be generated by adding $1000 to that RESULT value. For example, for RESULT value 13 (Referral), submit the amount 1013. If the amount is in this range but does not correspond to a PayPal result supported by this testing mechanism, RESULT value 12 (Declined) is returned
$2001+RESULT value 12 (Declined)
Credit Card TypeCredit Card Number
American Express378282246310005
American Express371449635398431
American Express Corporate378734493671000
Australian BankCard5610591081018250
Diners Club30569309025904
Diners Club38520000023237
Discover6011111111111117
Discover6011000990139424
JCB3530111333300000
JCB3566002020360505
MasterCard5555555555554444
MasterCard5105105105105100
Visa4111111111111111
Visa4012888888881881
Visa4222222222222
Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.
Processor-specific Cards
Dankort (PBS)76009244561
Dankort (PBS)5019717010103742
Switch/Solo (Paymentech)633110199999001
Leave a Comment

.NET and TLS

  • Before .NET 4.6 – TLS 1.1 is default and negotiations start down
  • .NET 4.6 – TLS 1.2 is default and negotiations start down
  • .NET 4.7 – the default value of this property is SecurityProtocolType.SystemDefault. This allows .NET Framework networking APIs based on SslStream (such as FTP, HTTP, and SMTP) to inherit the default security protocols from the operating system or from any custom configurations performed by a system administrator.
Leave a Comment

.net core api to retrieve dns records

Built a .net core api using swagger, dnsclient.net, and rollbar. Have a look here https://github.com/xavier-hernandez/dnsclient-api .

Here is the README:

I created a YAML file built on OpenAPI 3.0 standards for my endpoints(paths) and models. I generated the stub code on https://editor.swagger.io/ then tweaked, fixed, and updated the code. Creating the stub code really gives a great head start.

I kept authentication simple, it’s using an API key sent in the header request. Currently the API key is hardcoded to “1” but maybe later I’ll use a database or something to store API keys. I might host this somewhere if it’s something I find interesting to host. Tie it maybe to a MySQL/MariaDB database.

The library being used to retrieve DNS information is called DnsClient.NET https://github.com/MichaCo/DnsClient.NET and available as a nuget package.

I’m also using https://rollbar.com/ which is an easy way to log errors and information. Maybe if I host it on Azure I’ll use Application Insights.

Leave a Comment

Hide JSON properties in the result set if not set or null, using .net core 3.1 and Newtonsoft

Need to hide properties in your JSON result for a .net core API. Add the following line in your Startup.cs file. Just like below.

opts.SerializerSettings.NullValueHandling = NullValueHandling.Ignore

services.AddMvc(options =>
                {
                    options.InputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter>();
		    options.OutputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter>();
                })
                .AddNewtonsoftJson(opts =>
               {
                    opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    opts.SerializerSettings.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy()));
                    opts.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                })
                .AddXmlSerializerFormatters();

Leave a Comment

HTTP Error 500.35 – ANCM Multiple In-Process Applications in same Process (using IIS Express)

I got this error today and was causing me a headache. I stopped all apps running in IIS Express, tried switching releases, etc. But seems like this is a bug in Visual Studio 2019.

Stop your application, close the solution, delete the .vs folder in the solution, open it back up and it should work.

https://stackoverflow.com/questions/58246822/http-error-500-35-ancm-multiple-in-process-applications-in-same-process-asp-ne

Leave a Comment

.net core – launchSettings.json and gitignore

If your working with other developers this file should not be ignored within your .gitignore file. Its useful for environmental and other settings.

I’m not sure why the template I downloaded had it ignored. Seems like its been an issue for a while and has been corrected a few times.

https://stackoverflow.com/questions/47377058/should-i-ignore-launchsettings-json-file-from-being-committed-in-git

https://github.com/github/VisualStudio/issues/1405

Leave a Comment

Access Modifiers (C# Programming Guide)

All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:

public

The type or member can be accessed by any other code in the same assembly or another assembly that references it.

private

The type or member can be accessed only by code in the same class or struct.

protected

The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.

internal

The type or member can be accessed by any code in the same assembly, but not from another assembly.

protected internal

The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.

http://msdn.microsoft.com/en-us/library/ms173121.aspx

Leave a Comment

Change HTMLEncode In An Autogenerated Gridview

The only way I found to change the HtmlEncode property on a bound column when auto-generating the grid-view.

protected void grFeedHistoryView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            BoundField field = (BoundField)((DataControlFieldCell)e.Row.Cells[2]).ContainingField;
            field.HtmlEncode = false;
        }

 

Leave a Comment