The Shared Source CLI runtime is not intended for use as a secure environment, although its source code does provide a good example of how a secure execution environment can be implemented. By default, strong name verification is turned off for several important public keys.
The implementation of global assembly cache and strong name verification system in the SSCLI is completely separate from the implementation used by the commercial Microsoft® .NET Framework, and because of this, there should be no interaction between the two. Turning off verification in the SSCLI will not impact the .NET Framework on Microsoft® Windows® in any way.
Strong name verification is a mechanism which requires a developer or publisher of an assembly to have access to both the public and private elements of a cryptographic key pair at build time. The public key becomes part of the assembly name and a cryptographic hash of the metadata of the assembly is calculated using the private key and inserted into the assembly. At load time, strong name verification uses the public key to derive the metadata checksum which can be checked against the actual metadata thus proving that the producer of the assembly had access to the private key. More information on this process can be obtained from http://msdn.microsoft.com. The implementation of strong name verification can be seen in the SSCLI source tree in sscli\clr\src\dlls\mscorsn\strongname.cpp.
There is an additional distinction among strong names. All assemblies released in the .NET Framework that include classes specified in the ECMA-335 CLI standard are name with a special public key. This public key is cryptographically invalid and is treated as a special case by both the SSCLI and the .NET Framework strong name verification code.
In Microsoft's commercial .NET Framework implementation, when an assembly using this special public key is loaded, the strong name verification code will assume that the assembly is signed using the private Microsoft key. If it isn't signed with the Microsoft key then the assembly will not load unless strong name verification for the public key in that assembly is turned off.
In the SSCLI, when an assembly contains the special public key designated by ECMA, the strong name verification code will assume that the assembly is signed with the SSCLI private key, which can be found in sscli\clr\bin\rotorkeypair.snk. If it isn't signed with the SSCLI private key, the assembly will not load unless strong name verification for the public key of that assembly is turned off.
Note, the SSCLI private key is not in any sense a "private" key because it is published in the source distribution. Anyone can use it to sign any assembly and it signifies nothing with respect to security and ownership of the resulting binary.
Because the SSCLI distribution is a source distribution with a build process and because the private key used to sign the .NET Framework implementation of system assemblies can be used only for signing binary files published by Microsoft, the assemblies built during the SSCLI build process on your computer are "delay signed."
Delay signing (also called "partial signing") means that the public key is stored in the assembly metadata but the assembly file is not signed using the private key. In order for a delay signed assembly to load, strong name verification must be turned off. This is done using the Strong Name tool during the SSCLI build process (see sn.html). The default configuration for the SSCLI build environment is that verification is turned off for both the ECMA public key and the Microsoft public key.
All assemblies that can be found in both the SSCLI and in Microsoft's commercial .NET Framework use identical public keys: some contain the ECMA key and some contain the Microsoft public key. Any assemblies unique to the SSCLI contain the SSCLI public key in rotorkeypair.snk or rotorpublickey.snk. Note that no assembly built with the SSCLI key can be trusted with respect to origin, including assemblies built during the SSCLI build process. (Of course, you have control of the SSCLI source code on your computer, so you understand the level of trust to impart to your own build output.)
When an assembly B references an assembly A, compilers will store the full assembly identity, including the public key, in the assembly reference in assembly B. When either the SSCLI or the commercial .NET Framework load assembly B and attempt to resolve the types which reside in assembly A, the assembly loading infrastructure will only look for assemblies with the same public key as assembly A. Note that no information with respect to the cryptographic signature of assembly A is stored in assembly B - only the public key (usually a size-reduced hash of the public key). Cryptographic verification occurs when an assembly is loaded into the CLI execution environment. Thus, assemblies built against delay-signed assemblies are no different than assemblies built against fully signed assemblies, only the public key is transferred to the new assembly.
The SSCLI implementation is designed to facilitate sharing code and experimentation. Code built against one SSCLI installation should run against another SSCLI installation. It should also run against other ECMA-335 compliant CLI implementations, assuming only classes in the ECMA standard are used. No assumptions should be made, however, about the security of the SSCLI installation or of assembly code signed with the SSCLI key pair.
Some tools in the SSCLI are managed applications that must be run inside the SSCLI execution environment. This means they must be executed using the clix application launching utility. Managed applications are assemblies and in the SSCLI these assemblies are delay signed. Failure to use the clix launcher to execute a SSCLI managed tool on Windows will cause the tool to be executed under the .NET Framework. This will cause an error dialog that states that the utility may have been tampered with or was partially signed. This error is correct: the SSCLI utilities are partially signed and will not execute under the .NET Framework.
For example, if you forget to run clix caspol and instead just run caspol you
could see the resulting error dialog:
---------------------------
caspol.exe - Strong name validation failed.
---------------------------
Strong name validation failed for assembly 'C:\sscli\build\v1.x86fstchk.rotor\caspol.exe'. The file may have been tampered with or it was partially signed but not fully signed with the correct private key.
---------------------------
OK
---------------------------
If you see a similar error then make sure to use the clix launcher when
executing that
tool.
To build the Shared Source CLI implementation on Microsoft® Windows® XP requires Visual Studio .NET as stated in the readfirst.html.
The minimum installation of Visual Studio .NET required to support the Shared Source CLI is Visual C++® .NET. Within the options for installing Visual C++ .NET, the C runtime libraries must be selected because the runtime header files are required by the SSCLI build process.
A Perl distribution must be installed on Windows XP in order to build the Shared Source CLI source tree. For example, you can go to www.activestate.com and install the free download of Perl (preferably version 5.6.1 builds 630 and later).
The Perl installation must correctly modify your environment variables so that Perl is in your path. The env.bat file will search your path and will set the PERLLIB environment variable assuming there is a LIB directory that is a peer of the location where perl.exe is installed.
You must install Perl with administrator-level privileges. If you install the ActiveState Perl distribution while you are logged in with only user-level privileges, the installer will not be able to modify your environment variables and the Rotor build process will not work correctly.
The Shared Source CLI requires 256MB of memory to build in a performant way. People using FreeBSD installed on systems with 128MB of memory report that they must increase the available swap space to twice the default size (default is 2x memory) or at least 512MB. The build will proceed very slowly under this configuration but it will usually complete.
The first source release of the Shared Source CLI used makefiles that required the use of BSD make on FreeBSD 4.5. These makefiles were incompatible with other variants of the make utility. The makefiles in the current release have been modified to remove the dependency on BSD make.
Due to portability modifications to the security implementation, support for mapping URLs to security zones does not exist in the Shared Source CLI security implementation and all such mappings will return the zone of the local machine. For example, the static method System.Security.Policy.Zone.CreateFromURL() will always return the zone value of System.Security.Policy.SecurityZone.MyComputer. Thus care should be taken to understand this limitation if running code that relies on security zones generated via URLs.
In the first source release of the Shared Source CLI (SSCLI), the directory where user-configuration information was stored was %userprofile%\rotor on Microsoft® Windows® or ~/.rotor on FreeBSD. This caused the problems when trying to run checked, free, or fastchecked suites simultaneously since they all shared the same user configuration location. This has been changed to allow more complete side-by-side isolation of SSCLI builds.
The new user configuration directory name is created by generating a unique name based on a hash of the path to the platform adaptation layer (PAL) libarary (rotor_pal.dll on Windows and librotor_pal.so on FreeBSD). The new user configuration directory location is: %userprofile%\rotor\<hash>\ on Windows or ~/.rotor<hash> on FreeBSD where <hash> is a 40-character hash of the path to the PAL dynamic library.
For example, if your user name on Windows is jsmith then the per-user configuration settings directory would be something like:
C:\Documents and Settings\jsmith\rotor\clejgcjcdhmbcjpgllccjfagplehoohojacjmnho
Note: Named-shared objects are also named using this naming convention which will prevent contention for named objects during execution of code in other instances of the SSCLI.
To review the implementation of this naming convention, search for the
MangleObjectNameW() function and the associated global
variable NameManglerW in the source code in the PAL subdirectories.
There are several known problems that might occur when the just-in-time compiler implementation pitches code as it attempts to minimize the code heap size.
In some cases when an exception is thrown the code for methods on the stack has been pitched. This will cause the original starting address in StartOfTheMethod to be lost. For safety in this release of the SSCLI implementation, the offset is set to 0 to avoid pointing into unallocated memory. This means that the stack trace will always show the first line of the function for functions that have been pitched.
When the SSCLI implementation the CLI runs out of code heap space several different errors can occur:
The Shared Source CLI implementation cannot be installed to a location with spaces in the path name. Please extract the .tgz file into a directory location with no spaces in the name.
If you use Winzip to extract the archive you must turn off smart CR/LF conversions option. Some files in the Rotor archive may not extract correctly if this option is turned on. To turn off the option in Winzip go to the Options, Configuration…, menu item. On the Miscellaneous tab make sure the item labelled "TAR file smart CR/LF conversion" is unchecked.
When you are running one of the SSCLI implementations of a tool or utility on Windows you must make sure that the SSCLI build output directory is in your path before the .NET Framework binaries directories or errors will occur. For example, if you change into the .NET Framework directory which contains files like mscorwks.dll and mscorlib.dll and then attempt to run the Rotor version of metainfo.exe you will see an error like:
--------------------------- metainfo.exe - Entry Point Not Found --------------------------- The procedure entry point SetFusionShutdownCallback could not be located in the dynamic link library fusion.dll. --------------------------- OK ---------------------------
The Shared Source CLI implementation of the C# compiler does not accept wildcards in assembly version information attributes. For example, specifying the assembly version with the following attribute will cause the code to fail to compile:
[assembly: AssemblyVersion("1.0.*")]
It has been reported that compiling the FreeBSD kernel with some modified configuration options may cause the Shared Source CLI build process to fail. The symptom of the problem in the reported case was that the C# compiler would core dump when building the FX tree. Here's a snippet from the builddf.log file:
/out:/usr/local/src/sscli/build/v1.x86fstchk.rotor/private/lib/System.dll @objdf/rotor_x86/csc.rsp.lib Fatal error 'Can't create gc thread' at line ? in file /usr/src/lib/libc_r/uthread/uthread_create.c
The problem was solved by removing the following settings from the kernel configuration file and then recompiling the kernel:
# To use more memory per process options MAXDSIZ="(2048*1024*1024)" options MAXSSIZ="(256*1024*1024)" options DFLDSIZ="(1024*1024*1024)"
All the samples under the sscli\samples\pigui directory require Tcl and Tk to be installed on the system in order to execute. On FreeBSD these packages should be installed from the Packages collection. On Windows, one solution is to install the ActiveTcl 8.3.4.2 software from www.ActiveState.com.
Also, platform-independint UI (PIGUI) samples compiled under FreeBSD will not run under Windows.
The samples rely on platform invoke wrappers in sscli\samples\pigui\tk\tknative.cs which use a const value which contains either "tk83.dll" on Windows and "libtk83.so" on FreeBSD under a #if !PLATFORM_UNIX switch. Thus the sample applications build in the name of the Tk support dll which changes across platforms.
The version of the gdb debugger that installs by default on FreeBSD 4.5 has problems using the SOS debugger extension. You can obtain more information on using gdb and SOS in sscli\docs\techinfo\sostips.html.
Problem reports indicate that the version of gdb that ships with FreeBSD 4.5 may crash and core dump when used with the SOS debugger extension library. However, later versions of gdb do not seem to have this problem.
SOS is implemented as a dynamically loaded library, sos.dll on Windows, and libsos.so on FreeBSD. It can be loaded from the Windows SDK platform debuggers NTSD or WinDBG on Windows or gdb on FreeBSD, however the manner it which it is loaded is significantly different across the Windows and FreeBSD debuggers.
On Windows under NTSD or WinDBG, the SOS dll is loaded into the debugger process and it communicates across-process to obtain data from the process being debugged. On FreeBSD under gdb, extension libraries are loaded into the process being debugged and function calls are made to it from the debugger. The Shared Source CLI supports this loading procedure by means of a function in the core runtime library, libsscoree.so, which uses the PAL and the LoadLibrary() API to load the SOS library into the debuggee CLI process. The version of gdb that ships with FreeBSD 4.5 has a problem with the Shared Source CLI debugger extension implementation. This appears to have been fixed in current builds of gdb.
The Shared Source CLI implementation requires the released version of the Visual Studio .NET development system as the build environment. The build process will not work with the Visual Studio .NET beta2 release.
Symptoms of the problem are log file errors like:
Studio.NET\Vc7\PlatformSDK\Include\WinNT.h(4323) : error C2220: warning treated as error -
no object file generated C:\Program Files\Microsoft Visual
Studio.NET\Vc7\PlatformSDK\Include\WinNT.h(4323) : warning C4005: 'THREAD_BASE_PRIORITY_MIN' : macro redefinition
..\rotor_pal.h(1776) : see previous definition of 'THREAD_BASE_PRIORITY_MIN' C:\Program Files\Microsoft Visual
Studio.NET\Vc7\PlatformSDK\Include\WinNT.h(4324) : warning C4005: 'THREAD_BASE_PRIORITY_IDLE' : macro redefinition
..\rotor_pal.h(1777) : see previous definition of 'THREAD_BASE_PRIORITY_IDLE' C:\Program Files\Microsoft Visual
Studio.NET\Vc7\PlatformSDK\Include\WinBase.h(3797) : warning C4005: 'TLS_OUT_OF_INDEXES' : macro redefinition
..\rotor_pal.h(1802) : see previous definition of 'TLS_OUT_OF_INDEXES'
NMAKE : fatal error U1077: 'cl' : return code '0x2' Stop.
These particular errors are caused by changes to the macro definitions between the beta and release versions of Visual Studio. Since the Shared Source CLI was developed using the released version these macro definitions will not match.
Copyright (c) 2002 Microsoft Corporation