ASPNET Core websites, developping with SSL

ASPNET Core websites, developping with SSL

While working on the backend for To-Do.Studio, we ran into a scenario where we needed to test on a developer’s machine with https (ssl) enabled.

note – we use Kestral for testing and not IISExpress.

First thing we did was to try and add a https url in the LaunchSettings.json file. That didn’t work 🙂

What we found was that had to configure Kestral manually and tell it which certificate to use. The code in our Program class looks like this :

public static IWebHost BuildWebHost(string[] args) =>
   WebHost.CreateDefaultBuilder(args)
     .UseApplicationInsights()
     .UseAzureAppServices()
#if DEBUG
     .UseKestrel(t => {
        t.Listen(IPAddress.Loopback, 55172);
        t.Listen(IPAddress.Loopback, 55000, o =>
        {
            o.UseHttps("localhostCertificate.pfx", "password");
        });
     })
#endif
    .UseStartup<Startup>()
    .Build();

But how do we get a certificate ? There are various ways but i didn’t feel like finding my win32 sdk as some instruction’s on the web… so i decided to use my Ubuntu WSL…

Two commands

erik@ErikLAPTOP:~$ openssl req -x509 -days 10000 -newkey rsa:2048 -keyout cert.pem -out cert.pem
erik@ErikLAPTOP:~$openssl pkcs12 -export -in cert.pem -inkey cert.pem -out cert.pfx

and i had a good looking self made certificate. The hardest part was to copy this cert.pfx file to a Windows directory so i could use it my code.

VoilĂ  ! after modifying my LaunchSettings.json, i could test in either http or https mode !

"ToDoStudio.Server_http": {
 "commandName": "Project",
 "launchBrowser": true,
 "environmentVariables": {
 "ASPNETCORE_ENVIRONMENT": "Development"
 },
 "applicationUrl": "http://localhost:55172/"
 },
 "ToDoStudio.Server_https": {
 "commandName": "Project",
 "launchBrowser": true,
 "environmentVariables": {
 "ASPNETCORE_ENVIRONMENT": "Development"
 },
 "applicationUrl": "https://localhost:55000/"
 }

Windows 10 Redstone 4

Well, as you all know, windows 10 Fall Creators Update is out (internally named Redstone3) and those of you who are Windows Insiders have started getting bits Redstone 4, which should go out in the spring and doesn’t have a public name yet…

In case you are reading Microsoft, this is what i would like to see…

  1. With Windows 10 ARM devices coming out soon…
    • Make Cortana better, make her take more real estate on the screen and not just a small popup where i am always scrolling. Innovate in tablet scenarios.
    • Make Windows Explorer a bit better in tablet mode, maybe tabs
    • Make the tablet experience one or two steps better, i miss swiping from the left quickly to change apps from my Windows 8 RT tablet.
  2. Upgrade Skype
    • Make Skype UWP better, allow to login with Microsoft work account and offer Skype4Business functionality. I don’t want to have two apps doing the same thing. OneDrive managed to do it, you do it also. It would be ok if Skype4Business functionality was in both Skype and Teams.
    • Make SMS sync work for each platform without bugs with mms support.
  3. Finalize Andromeda and Continuum, make it awesome, any Windows 10 device displays itself in the proper way according to how it’s being used.
  4. Upgrade networking, i use a LTE dongle which i cannot even mark as a metered network, innovate in the space somehow to bring innovation in the way in which we connect to wifi networks, lte or share the internet. At the same time, please have an automatic VPN mode for public networks.
  5. Innovate in sharing and continuing work…
    • Cloud Clipboard (was suppose to be in RS3)
    • Windows TimeLine (was suppose to be in RS3)
    • OneNote and Edge on every platform where everything syncs magically
  6. Surprise everyone with Edge
    • make it support PWA and all modern features, you are almost there
    • make it a rock hard stable, you are almost there
    • offer a few more innovations, you can do it !
  7. OneNote UWP should become a premier tool, deprecate the win32 version and make it ubiquitous
    1. Writing on webpages in Edge should not be a Edge feature but a feature of OneNote. It should work in any context over any app
    2. The Ink Workspace should revolve around OneNote
    3. Make OneNote accept personal and work accounts for synching like OneDrive
    4. Get rid of sticky notes,  OneNote should be my sticky notes app
  8. Make up your mind with the UWP office apps (Excel, Word, outlook, powerpoint). Stop having two flavours and be bold. I would prefer the UWP versions because sometimes less is more.
  9. Have a family mode which works on the lock screen or in a guest mode – i see this as a part of Andromeda and Continuum when the device is locked or we don’t’ know who is using the device, allow to browse the web in a inprivate session. There might be something called family apps in the store that are specialised to run without a user being logged in.
  10. Have a dongle based on windows 10 arm that has a hdmi plug, wifi, Bluetooth and a few usb ports. It can be plugged into a monitor to offer a full desktop or miracast receiver experience. Plugged into a tv for a tv experience. In enterprise this could replace thin clients or chromecasts in boardrooms. It also has to be cheaply priced.
  11. Get your media story together, after dropping Groove subscriptions, i feel tv is the next thing. Partner instead of dropping, you need presence in this space.
  12. Office personal and Ofice365 should have deeper integrations into the OS. I feel i am always on the web for these services
  13. Upgrade WSL to have a built-in wayland display server
  14. Upgrade WSL to bring Android apps to Windows 10 all factors, if you can’t beat them join them. Apps should be downloaded from the Store. If there were three major android stores (Google, Amazon and Microsoft), i think we could start moving towards shared api and not the closed Google Play apis… Xamarin could maybe provide that api…
  15. Keep on fighting and have presence in the mobile and tablet form factor, continue the Window S concept for low price points (but always upgradable if necessary)

Protected: The art of Debugging

This content is password protected. To view it please enter your password below:


The Microsoft Graph

One of the project i was working on involves taking Office 365 to the next level. Take the tools that Microsoft gives us and bring it to the next level.

Some of the things we do involves extending Sharepoint, Excel, Word, Office with addons. Works great. But where do we get all the nice information we show the user ?

This is where the Microsoft Graph comes in (http://graph.microsoft.com). It is basically an odata feed that gives you access to a variety of data that represents you. Naturally, you need to send a bearer token to get access so authenticate first !

You can find then entire “metadata” on the internet itself, all self-describing ! Also, there is some documentation.

You can even try the Graph Explorer, which is a web tool to explore the graph in an interactive way.

Here a are a few example of me for my own company :

Who am i ?

GET https://graph.microsoft.com/v1.0/me
{
 "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
 "id": "",
 "businessPhones": [],
 "displayName": "Erik Renaud",
 "givenName": "Erik",
 "jobTitle": "Principal Architect",
 "mail": "erik.renaud@modelon.net",
 "mobilePhone": "+1 514...",
 "officeLocation": "+1.514...",
 "preferredLanguage": "en-CA",
 "surname": "Renaud",
 "userPrincipalName": "erik.renaud@modelon.net"
}

What about my picture ?

GET https://graph.microsoft.com/v1.0/me/photo/$value

 

This is a goldmine of information and makes any business tool soo much more powerful.

Add  an email, find recently used files, show how many unread things in teams… It’s all possible !

 

 


Mocking web services

For one of the projects i manage i have two teams and in the end, one implements web services for the other to consume. In production and integration testing, things tend to go well. But when we are faced with debugging or testing the side that consumes web services, we need something more.

I love do discover new things or new ways of doing things, enter EasyMock (https://github.com/CyberAgent/node-easymock). It is a small nodejs web server that returns any file on disk with extra options in it’s config.json file.

You install it with :

$ npm install -g easymock
And you start it within your work directory with :
$ easymock
Server running on http://localhost:3000
Listening on port 3000 and 3001
Documentation at: http://localhost:3000/_documentation/
Logs at: http://localhost:3000/_logs/

If you wanted to mock a CurrentUserCount rest web service which is located at /api/CurrentUserCount, all you need to do is create a “api” directory with a file named “CurrentUserCount_get.json” within it. Here is that result :

There is even a handy automatically created documentation page:

Happy mocking !


My #HitRefresh moment

As a @Microsoft MVP, i got an award for helping people with technology. I can give a talk, i can coach a team, but how do help more. Here is my #HitRefresh moment:

Working collaboratively is hard, yet it is the basis ouf of how we live – we have families, we have collegues and we have friends. When we realised how hard this problem was to solve; we #HitRefresh and rethought how digital tools can help us work together and accomplish more : a studio for all of your things to do.

We are not ready yet, but we are working hard to bring it to you soon.

This post is part of the collection of #HitRefresh moments. Read more at www.hitrefreshbook.com


Custom nuget feeds with Visual Studio Online Build

So I was working on DayTickler, and we suddenly decided to start using Xamarin controls from Telerik(Progress) and Syncfusion. Traditionally, that usually meant downloading the installer and then referencing the proper assemblies from the local drive. Another workflow was to copy the assemblies to the project directory in some sort of “lib” folder so that those assemblies could be used in a CI environment.

Fast forward to 2016  and we have something called Nuget, so i tried using these to achieve the same objective. The first was to add the two nuget feeds to Visual Studio’s Nuget configuration screen. Easy enough and from there, i was able to provide my Telerik credentials (their feed is private) and install the packages. Yay !

But when you commit to Visual Studio Online, there is no way to build because it would now fail on package restore.

The solution is to:

1 – Create a nuget.config file in the solution so that the build server knows where to download nuget feeds from:

2 – Open your build definition, and in the “Feeds and authentication” section, go point to your nuget.config file:

3 – Press “+” near “Credentials for feeds outside the account/collection”, and add the appropriate details.

 

That’s it ! worked like a charm and there is a “Verify connection” button to ensure all is good.


For enterprises, creating a web site that can link to files stored locally to work with “desktop apps”

One of my clients wanted a way to interact with local files (open folders, launch the associated application) from a web page. In this way, they could construct home page for the user and link to “local files” the same way as if they were on the internet.

This worked using IE (not Chrome nor Edge) through the file protocol. You could effectively do this :

<a href="file://t:\data">Data directory</a>
<a href="file://t:\data\file.txt">text file</a>

And the web page (on IE) would render two links, which would either open the folder in explorer or the file in notepad.

How would you fix this problem with Chrome and Edge ?

What we have prototyped is the creation of a UWP app that registers two URL protocols. Then you simply use these protocols in your web page and the UWP app will handle the request and do something, effectively bridging the gap between web and desktop…

Here is the updated HTML:

<a href=”myAppOpenFolder://t:\data”>Data directory</a>
<a href=”myAppOpenFile://t:\data\file.txt”>text file</a>

Once that is done, you need to create a new UWP app and register your new protocol declarations in the manifest, it should look like this:

<Extensions>
 <uap:Extension Category="windows.protocol">
 <uap:Protocol Name="myAppOpenFolder">
 <uap:DisplayName>myAppOpenFolder</uap:DisplayName>
 </uap:Protocol>
 </uap:Extension>
<uap:Extension Category="windows.protocol">
 <uap:Protocol Name="myAppOpenFile">
 <uap:DisplayName>myAppOpenFile</uap:DisplayName>
 </uap:Protocol>
 </uap:Extension>
 </Extensions>
 </Application>
 </Applications>

Once the manifest is done, you simply handle the situation in you app.cs:

protected override void OnActivated(IActivatedEventArgs e)
{
if (e.Kind == ActivationKind.Protocol)
{
var protocolArgs = e as ProtocolActivatedEventArgs;

if (protocolArgs.Uri.Scheme == “myAppOpenFolder”)
{
Windows.System.Launcher…. (protocolArgs.Uri);
}
else if (protocolArgs.Uri.Scheme == “myAppOpenFile”)

{
Windows.System.Launcher…. (protocolArgs.Uri);
}

base.OnActivated(e);
}
}