How to create a Token Server using Identity Server 4 - Video

by sunil ravulapalli /23. August 2016 07:01 / /Comments (0)

This video will show you how to create a Token Server using Identity Server 4

How to bind SSL to a SEQ Server on an Azure VM

by sunil ravulapalli /29. June 2016 02:39 / /Comments (0)

Step 1: Generate a CSR to request a certificate.

You can use OpenSSL like this:

Openssl req -newkey rsa:2048 -nodes -keyout newcert.key -out newcert.csr

Send the CSR file to your IT department so that they can generate a cert using you intranet certificat authority

Step 2: Generate a PFX file

Run this command using OpenSSL to generate the PFX

openssl pkcs12 -export -out newcert.pfx -inkey newcert.key -in certITGaveYou.cer -certfile yourcompanyrootcert.cer

Step 3: Import certificate chain into your Azure VM

Step 4: Run these commands at the SEQ command line

seq stop
seq uninstall
seq bind-ssl --thumbprint="THUMBPRINT HERE"
seq install --listen="https://YOURSERVER"
seq start

Step 5: Open up the 443 port in Azure portal for your VM

Step 6: Open up the 443 port in Azure VM

Open SSL command to package key and cer file to pfx

by sunil ravulapalli /29. June 2016 02:36 /openssl /Comments (0)
openssl pkcs12 -export -out newcert.pfx -inkey newcert.key -in newcert.cer -certfile root.cer

If you get a unable to load error, try installing the newcert.cert certificate into the cerificate store and then do an Export to .cer file.

Openssl command to generate a CSR

by sunil ravulapalli /29. June 2016 02:34 / /Comments (0)
Openssl req -newkey rsa:2048 -nodes -keyout newcert.key -out newcert.csr

How to create a IdentityServer4 Server

by sunil ravulapalli /22. June 2016 08:09 / /Comments (0)

All code is from IdentityServer4.Samples githib repo

1. Create an ASP.NET Core Web Application

2. Choose Web Application

3. Choose No authentication

4. Add a Nuget package called IdentityServer4 v1.0.0-beta3(Remember to include prereleases in search)(This version is latest as of June 2016)

5. Get a pfx certificate.(For test purposes get this idsrv3test.pfx from here, you download this file right click on it choose DO NOT DO "Save as". For some reason the certificate does not work this way. Just click on it one, which takes you to the "raw". Just click the "Raw" link to download it.

6. Add a folder called Configuration and add these files Clients.cs, Scopes.cs and Users.cs

using IdentityServer4.Models;
using System.Collections.Generic;
public class Clients
	public static IEnumerableList<Client> Get()
		return new List<Client>
			new Client
				ClientName = "Resource owner Client",
				ClientId = "roclient",
				ClientSecrets = new List<Secret>
					new Secret("madeupsecret".Sha256())

				AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,

				AllowedScopes = new List<string>

using IdentityServer4.Models;
using System.Collections.Generic;

public class Scopes
	public static IEnumerable<Scope> Get()
		return new List<Scope>

			new Scope
				Name = "api1",
				DisplayName = "API 1",
				Description = "API 1 features and data",
				Type = ScopeType.Resource

using IdentityModel;
using IdentityServer4;
using IdentityServer4.Services.InMemory;
using System.Collections.Generic;
using System.Security.Claims;

public class Users
	public static List<InMemoryUser> Get()
		var users = new List<InMemoryUser>
			new InMemoryUser{Subject = "818727", Username = "alice", Password = "alice",
				Claims = new Claim[]
					new Claim(JwtClaimTypes.Name, "Alice Smith"),
					new Claim(JwtClaimTypes.GivenName, "Alice"),
					new Claim(JwtClaimTypes.FamilyName, "Smith"),
					new Claim(JwtClaimTypes.Email, ""),
					new Claim(JwtClaimTypes.EmailVerified, "true", ClaimValueTypes.Boolean),
					new Claim(JwtClaimTypes.Role, "Admin"),
					new Claim(JwtClaimTypes.Role, "Geek"),
					new Claim(JwtClaimTypes.WebSite, ""),
					new Claim(JwtClaimTypes.Address, @"{ 'street_address': 'One Hacker Way', 'locality': 'Heidelberg', 'postal_code': 69118,'country': 'Germany' }", Constants.ClaimValueTypes.Json)

		return users;

7a. Create a IEnvironment variable in Startup.cs

private readonly IHostingEnvironment _environment;

7b. Get a reference to the concreate env in the constructor

_environment = env;

7c. Load certificate like this in the ConfigureServices method

var cert = new X509Certificate2(Path.Combine(_environment.ContentRootPath, "idsrv3test.pfx"), "idsrv3test");

7d. Configure Clients, Scopes and Users like this

var builder = services.AddIdentityServer()

In the Configure method, add


Now to test it out, lets use the the Postman extention in Google Chrome browser.

8. Create a new request and in the Authorization tab choose Basic and put the username password as we set up in the client i.e. Username: roclient, Password=madeupsecret and hit update request. This will add a row in the header tab.

9. Add more the following entries in the header section like this:


10. Add following entries to the Body tab:



Apex code for tansaction/savepoint

by sunil ravulapalli /20. September 2014 05:32 / /Comments (0)
Savepoint sp = Database.setSavepoint();
       insert residence;
       insert income;
       insert additionalIncome1;
catch(DmlException e) 
       residence.Id = null;
       income.Id = null;
       additionalIncome1.Id = null;
       return null;

Wix code for Windows service

by sunil ravulapalli /20. September 2014 05:22 /wix /Comments (0)
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="">
  <?define ProductManufacturer="Company Financial" ?>
  <?define ProductName="Company Decisioning Service" ?>
  <?define UpgradeCode="0905ba53-804e-4fb4-af5e-5e21cca3b0b0" ?>
  <Product Name="$(var.ProductName)" Id="*" UpgradeCode="$(var.UpgradeCode)" Manufacturer="$(var.ProductManufacturer)" Version="$(var.ProductVersion)" Language="1033">
    <Package Manufacturer="$(var.ProductManufacturer)" InstallerVersion="200" Languages="1033" Compressed="yes" />
    <Media Id="1" Cabinet="" EmbedCab="yes" />
    <UIRef Id="WixUI_InstallDir" />
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
    <WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
    <WixVariable Id="WixUIBannerBmp" Value="Company_banner.jpg" />
    <WixVariable Id="WixUIDialogBmp" Value="Company_dialog.jpg" />

    <Property Id="ARPPRODUCTICON" Value="Company.ico" />
    <Icon Id="Company.ico" SourceFile="Company.ico" />
    <!-- Version Upgrade Logic -->
    <Upgrade Id="$(var.UpgradeCode)">
      <!-- Check for an older installed version and allow it to be automatically uninstalled and the new version installed in its place. -->
      <UpgradeVersion Minimum="1.0.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" OnlyDetect="no" Property="PREVFOUND" />
      <RemoveExistingProducts After="InstallInitialize"/>
    <!-- End Version Upgrade Logic -->
    <Feature Id="ProductFeature" Title="$(var.ProductName)" Level="1">
      <ComponentRef Id="CompanyDecisioning" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder" Name="PFiles">
        <Directory Id="INSTALLDIR" Name="Company Decisioning Service">   
    <Component Id="CompanyDecisioning" Guid="{0577f44c-782d-457e-9738-152ba678f9bc}" Directory="INSTALLDIR">
      <File Id="Company.Decisioning.WinService.exe" Name="Company.Decisioning.WinService.exe" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\Company.Decisioning.WinService.exe" Vital="yes" KeyPath="yes" DiskId='1'/>
      <File Id="App.config" Name="Company.Decisioning.WinService.exe.config" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\Company.Decisioning.WinService.exe.config" Vital="yes" KeyPath="no" DiskId="1"/>
      <File Id="Company.Data.dll" Name="Company.Data.dll" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\Company.Data.dll" Vital="yes" KeyPath="no" DiskId="1"/>
      <File Id="Company.Core.dll" Name="Company.Core.dll" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\Company.Core.dll" Vital="yes" KeyPath="no" DiskId="1"/>
      <File Id="Company.Service.dll" Name="Company.Service.dll" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\Company.Service.dll" Vital="yes" KeyPath="no" DiskId="1"/>

      <File Id="EntityFramework.dll" Name="EntityFramework.dll" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\EntityFramework.dll" Vital="yes" KeyPath="no" DiskId="1"/>
      <File Id="EntityFramework.SqlServer.dll" Name="EntityFramework.SqlServer.dll" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\EntityFramework.SqlServer.dll" Vital="yes" KeyPath="no" DiskId="1"/>
      <File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\Newtonsoft.Json.dll" Vital="yes" KeyPath="no" DiskId="1"/>
      <File Id="Microsoft.AspNet.Identity.Core.dll" Name="Microsoft.AspNet.Identity.Core.dll" Source="..\Company.Decisioning.WinService\bin\$(var.Configuration)\Microsoft.AspNet.Identity.Core.dll" Vital="yes" KeyPath="no" DiskId="1"/>

      <ServiceInstall Id="ServiceInstaller" Name="DecisioningService" Type="ownProcess" Vital="yes" DisplayName="Company Decisioning Service" Description="This service sends application decisions." Start="auto" Account="NT AUTHORITY\LocalService" ErrorControl="ignore" Interactive="no" Arguments=" /start DecisioningService"/>
      <ServiceControl Id="StartService" Name="DecisioningService" Start="install" Stop="both" Remove="uninstall" Wait="yes" />

How to play around with Asp.Net vNext - Project K

by sunil ravulapalli /10. July 2014 00:10 /aspnetvnext /Comments (0)

This video shows you how to easily play around with Asp.Net vNext - Project K using a ready to use azure virtual machine.

Xunit using F#

by sunil ravulapalli /17. May 2014 06:01 /.net /Comments (0)

Create new F# Library project. Install Xunit from Nuget Create a class called MyTest.fs like this

module MyTests  
open Xunit

type myTest1() = class

    member self.myTest() =
       Assert.Equal(1, 1);


Build it, and then, just right click any where on the myTest1 method and choose Run Test. In the Test Explorer Window you should see the test run succesfully.

How to use Ninject in ASP.NET MVC 5 and WEB API 2

by sunil ravulapalli /30. April 2014 05:17 / /Comments (0)

Dependency injection frameworks are becoming a common place in all modern code bases. One of the most popular dependency injection framework in the .NET world is Ninject. This post will show a very simple example of how you can get started with Ninject. Check it out here: