Compare commits

...
Author SHA1 Message Date
Rodrigo Kumpera f5fbc321b4 Merge pull request #3916 from ludovic-henry/4.8-fix-suspend-watchos
[4.8][threads] Fix suspend on watchos
2016-11-14 14:05:24 -05:00
Rodrigo Kumpera 890670ab80 Merge pull request #3917 from ludovic-henry/4.8-fix-suspend-posix
[4.8][threads] Fix Posix async resume
2016-11-14 14:05:12 -05:00
Rodrigo Kumpera fab452a7a8 Merge pull request #3918 from ludovic-henry/4.8-fix-threadpool-hang
[4.8][threadpool] Fix hang on domain unloading
2016-11-14 14:04:57 -05:00
Martin Baulig 3fac1383a3 [BTLS]: Use host name without port for the Server Name Indication (SNI). Bug #46549. (#3939) 2016-11-14 15:05:01 +01:00
Miguel de Icaza db3db35fe8 Backport fix from Aleksey 2016-11-11 12:29:26 -05:00
Martin Baulig 20e0914e03 [BTLS]: Use host name without port for the Server Name Indication (SNI). Bug #46549. 2016-11-11 16:42:12 +01:00
Joao Matos 2949ce7ead [offsets-tool] Fixed the Makefile to clone into the base directory instead. 2016-11-11 12:58:34 +00:00
Ankit Jain 868c619fd0 [xbuild] Don't reevaluate project when setting metadata in a dynamic ..
.. item.

If we have a project, that sets some properties or items at runtime,
like in a target:

```
        <Target Name="Build">
                <PropertyGroup>
                        <Bar>Bar01</Bar>
                </PropertyGroup>
```

.. such a property can be accessed as `$(Bar)` subsequently.

Then at later point, a target tries to update metadata on an item group
with existing items, like:

```
	<ItemGroup>
		<FooItem Include="xyz" />
	</ItemGroup>

	<Target Name="Foo">
                <ItemGroup>
                        <FooItem>
                                <SomeMetadata>MetadataValue</SomeMetadata>
                        </FooItem>
                </ItemGroup>
```

.. then it is seen that the value for the earlier created `$(Bar)` disappears!
So, if we try to print the value of `$(Bar)` right after that item
group, it would appear as `''`!

The issue is that the metadata update in target `Foo` caused the project
to get re-evaluated, which meant that items/properites created after the
project load were lost! We should not be reevaluating the project when
setting metadata on the basis of dynamic items, like in the target
`Foo`.

These dynamic item groups in a target are represented as
`BuildItemTask`, and these create BuildItems which have their
`IsDynamic` property set. And this is used to avoid re-evaluating the
project in `BuildItem.SetMetadata`.

But when updating metadata (`BuildItem.UpdateMetadata`), we need to
update metadata on the *existing* items, which might not have been
created from such dynamic item groups! So, their `IsDynamic==false`.
Hence, trying to `SetMetadata` on such items would cause the project to
be reevaluated, and thus properties/items like `$(Bar)` would be lost!

Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=45137

In this particular case, `Bar` was the `DesignTimeBuild` property, which
was losing it's value when `ProjectReference`'s `AdditionalProperties`
metadata was set in:

```
 <Target Name="BclBuildAddProjectReferenceProperties"
    <ItemGroup>
      <ProjectReference>
         <AdditionalProperties>$(_BclBuildProjectReferenceProperties);%(ProjectReference.AdditionalProperties)</AdditionalProperties>
     </ProjectReference>
    </ItemGroup>
```
2016-11-10 18:19:27 -05:00
Rodrigo Kumpera 8093a8f124 Merge pull request #3934 from lewurm/mono-4.8.0-arm64-fixed-cacheline-size-for-flushing
[C9][arm64] always assume a cache line size of 4
2016-11-10 14:41:04 -08:00
Bernhard Urban 9182938d25 [arm64] always assume a cache line size of 4
otherwise we still have the theoretical chance of a race.
2016-11-10 23:36:02 +01:00
Joao Matos f63ae59412 [offsets-tool] Updated build scripts to handle multiple platforms. 2016-11-10 19:28:35 +00:00
Joao Matos 77a1de7001 [offsets-tool] Fixed whitespace inconsistency. 2016-11-10 19:28:34 +00:00
Joao Matos 230cd898d1 Updated offsets tool to latest CppSharp. 2016-11-10 19:28:33 +00:00
Marek Safar d3399c8233 [System.Xml] Add XElement array handling to serialization interpreter. Fixes #12571 2016-11-10 18:43:51 +01:00
Zoltan Varga f3857e2a10 [runtime] Fix the ios build.
(cherry picked from commit c8ae9af395)
2016-11-10 17:26:23 +01:00
Alexander Köplinger a6ef4bc024 Add mono-package-runtime to EXTRA_DIST
The file was added in 15b6ef60e4
(cherry picked from commit 844b800098)
2016-11-10 15:33:37 +01:00
Alexander Köplinger 0bb2b5c69b Fix tarball build
(cherry picked from commit 8e8dcd24e4)
2016-11-10 15:05:27 +01:00
Jo Shields ee6362dff3 Add EXTRA_DIST listing all the files from btls
Apparently there's no way to get CMake to just spit out its own uncached variables, so we can't do this programatically.

(cherry picked from commit 6843f6d61d)
2016-11-10 15:05:27 +01:00
Jo Shields de92ba6397 Remove useless BTLS_DEPS variable
(cherry picked from commit 503b18e07f)
2016-11-10 15:05:26 +01:00
Zoltan Varga 6094da8d8e [sdb] Avoid asserting when trying to single step on a thread with no managed frames. Fixes #34802. 2016-11-09 21:59:41 -05:00
Zoltan Varga f42685a7ef [sdb] Avoid asserting when trying to single step on a thread with no managed frames. Fixes #34802. 2016-11-09 14:53:12 -05:00
Alexander Köplinger def42333a4 [System] Fix a few type members on WatchOS
The .platformnotsupported.cs versions of some classes were
inconsistent with their "real" counterparts.

(cherry picked from commit 10f86fb5fe)
2016-11-09 20:21:42 +01:00
Alexander Köplinger 4c3e3e9760 [btls] Include stdint.h header file in btls-time64.c
Fixes "error: unknown type name 'int64_t'" on Alpine/musl libc.

(cherry picked from commit 941bf17f1b)
2016-11-08 20:06:34 +01:00
Ludovic Henry 7def1ee268 [threadpool] Fix hang on domain unloading (#3904)
Because we wouldn't return the correct ThreadPoolDomain for the requested domain, we would simply wait on the last inserted MonoDomain. This would lead to a hang when unloading the domain, as we wouldn't wait on the correct domain.
2016-11-08 12:11:25 -05:00
Ludovic Henry ca9e4a836e [threads] Fix Posix async resume (#3861)
If we fail to send the signal, we should not add a pending operation, as the signal handler is never going to answer this operation (via mono_threads_notify_initiator_of_resume).
2016-11-08 12:08:33 -05:00
Ludovic Henry c606270c9b [threads] Fix suspend on watchos
Because certain platform (such as WatchOS) do not support syscall abort, we need to ensure that it is supported before we call the `mono_threads_suspend_abort_syscall` function.
2016-11-08 12:04:35 -05:00
Zoltan Varga ace3b63d26 [arm64] Set a flag in MonoContext if the fp regs are saved, and only restore them if they are. These registers are not saved when the context is created from a ucontext. (#3890) 2016-11-08 11:19:00 -05:00
Zoltan Varga 800dbae049 [arm64] Save+restore fp regs from the context in the call filter trampoline, the JITted code doesn't use them, but if the called code throws an exception, the throw context for the inner throw needs to contain the same values as the original throw context. (#3877) 2016-11-08 11:18:52 -05:00
Alexander Köplinger 128491307c [corlib] Add Marshal.CleanupUnusedObjectsInCurrentContext() stub
https://github.com/dotnet/standard/issues/94
(cherry picked from commit 05b68a1d35)
2016-11-08 12:47:16 +01:00
Alexander Köplinger 479888bec9 [corlib] Expose Marshal.PtrToStringBSTR on mobile
The SecureStringHelper from referencesource I added in #3887
relies on this to convert from SecureString to plaintext.

It failed on mobile because we always throw a NotImplementedException there,
but we actually have an implementation on the runtime side (even in the DISABLE_COM case).

(cherry-picked from df1475d95e)
2016-11-08 12:42:24 +01:00
Aleksey Kliger (λgeek) c55bf4ad91 Merge pull request #3886 from lambdageek/c9-46250
[C9][runtime] Ensure generic type definition arity matches generic context arity
2016-11-07 15:19:05 -05:00
Alexander Köplinger e6b9ba8908 [System.ServiceModel] Recognize 'faultactor' in SOAP fault message
It's an optional element according to [1] and we were simply
throwing a NotImplementedException when encountering it.

Fixed by reading the element value instead. I noticed that we
had a 'details' variable that was never assigned, so the check
for `details == null` was always true and can be removed.
This makes inlining the body of the CreateFault() call easier
since we no longer need to choose different overloads and makes
the code consistent with the CreateFault12 method.
Also added a better exception in case of an unrecognized element.

The CreateFault12 method (handles SOAP 1.2) does not need a similar
fix since actor is not an element in that version [2].

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42226

[1] https://www.w3.org/TR/soap11/#_Toc478383507
[2] https://www.w3.org/TR/soap12/#soapfault

(cherry picked from commit 69b3397c8e)
2016-11-07 18:25:39 +01:00
Martin Baulig 2365067bda [BTLS]: Use int64_t instead of long in the native API. (#3857)
* [BTLS]: Use `int64_t` instead of `long` in the native API.

* Copy time64.c from Android's source code to get a 64-bit timegm64().

* Rename into btls_timegm64() and remove everything we don't need.
2016-11-07 18:23:42 +01:00
Marek Safar dea12ad837 [mcs] Consider method candidates with misplaced named arguments not applicable. Fixes #46190 2016-11-04 18:36:18 +01:00
Marek Safar 161569b8ba [mcs] Remove debug check 2016-11-04 18:36:09 +01:00
Marek Safar 504fd1bea6 [mcs] More work on debug scopes declared out of order. Fixes #45774 2016-11-04 16:05:44 +01:00
Alexander Köplinger f4b4f97fc8 [System] Replace NetworkCredential with referencesource
Fixes an issue where the Mono implementation wasn't converting
between the SecureString and the plaintext version of the password.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44109

(cherry picked from commit 3d10e1c039)
2016-11-04 13:53:44 +01:00
Aleksey Kliger 76c1bcb099 [runtime] Ensure generic type definition arity matches generic context arity
Don't instantiate generic type definitions (like Dictionary`2) with too few or too many
type arguments.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=46250
2016-11-03 17:25:36 -04:00
Aleksey Kliger 4bf6c02cc0 [tests] Test System.Type.GetType() on generics with wrong arity. 2016-11-03 17:25:36 -04:00
Marek Safar c7cb8e90ad Merge pull request #3882 from radical/mono-4.8.0-branch
[mcs] Accept and ignore command line args supported by csc that we don't
2016-11-03 16:27:39 +01:00
Ankit Jain 8dc83f0c68 [mcs] Accept and ignore command line args supported by csc that we don't
.. support:

	/deterministic+
	/deterministic-
2016-11-03 11:25:28 -04:00
Ludovic Henry d2927b605a [4.8][hybrid-aot] Make it work on Android (#3872)
* [aot-compiler] Add generic class and gsharedvt for hybrid AOT mode

* [aot-compiler] Remove dead code

* [hybrid-aot] Add --hybrid-aot for future use

* [aot-compiler] Cleanup GSharedVT check

* [aot-compiler] Enable partial sharing for hybrid AOT

* [aot] Enable GSharedVT for Android

* [aot] Ensure GSharedVT is supported at runtime as well as compile time

* [aot] Factor aot mode setting
2016-11-03 11:05:03 -04:00
Ludovic Henry 972c7e8998 Remove exception when using SO_REUSEADDR on Linux (#3856) (#3873)
SO_REUSEADDR and SO_REUSEPORT are fundamentally different. This
exception seems to have been put in place to address the lack of
the latter on older Linux kernels for TCP. However, the change in
fact raises an exception when SO_REUSEADDR is used, which causes
failures in server applications, which may use SO_REUSEADDR to
avoid WAIT state timeouts.

Description of SO_REUSEADDR and SO_REUSEPORT differences:

http://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t

Some problems caused by raising this exception:

https://github.com/zeromq/netmq/issues/623
https://github.com/zeromq/netmq/issues/592
https://github.com/fsprojects/IfSharp/issues/90
2016-11-03 10:59:47 -04:00
Miguel de Icaza a87e8cd4a9 [mkbundle] Fix the argument order to put the entry point on argv[1] (#3880)
* [mkbundle] - Add support for bundling native libraries.

* [mkbundle] add support for bundling native libraries

* [glib] add g_mkdtemp

* mono: Load the various library payloads for bundled executables

* [msvc] Export mono_dl_open and mono_loader_register_module

* [scripts] Add script to package the basic runtime to reuse by mkbundle

* [mkbundle] Add diagnostics, fix crash, fix registered path to match runtime name on embedded MonoImages (#3669)

* Resolve

* Complete the work, it should be working now

* Remove stray code from cherry pick

* [mkbundle] Fix the argument order to put the entry point on argv[1]
2016-11-03 10:58:29 -04:00
Alexander Köplinger 26cf538ac6 [System] Disable a test that reads a file on mobile
We don't have a way to pass the file to our mobile test runners at the moment.
2016-11-03 10:29:55 +00:00
Joao Matos e27a0c066f [System.IO.Compression] Fixed potential bug when keeping track of total read bytes of input stream.
This didn't manifest as a bug, to to be on the safe side, replicate the behavior
introduced in https://github.com/mono/mono/commit/b4d5016b5e42fec226d93fd13260b6cac80eb384
and use the same approach when calculating the total of the read bytes of the input stream.
2016-11-03 10:29:53 +00:00
Joao Matos 204d3695c7 [System.IO.Compression] Fixed DeflateStream input stream EOF condition.
What was happening is that we set the stream EOF flag to true when we
could not read any more input data, and that made us early out before
fully finishing the processing of the compressed data.

Now the only EOF flag is set to true is if zlib's inflate() has actually
finished processing the data.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44994#c2.
2016-11-03 10:29:52 +00:00
Joao Matos 75cd6fb9f8 [System.IO.Compression] Fixed DeflateStream inflate() decompression loop.
This reworks the fix from https://github.com/mono/mono/commit/7c4d41a518aaf0370b882f9430752ebcd5544c10.

That fix introduced a regression when handling some inputs, which lead us to ignore
some left-over data from zlib's inflate output buffer.

Now we only break from the loop if inflate() returns Z_BUF_ERROR.

This makes sure all data is fully processed before returning to managed code.

Fixes one of the bugs in https://bugzilla.xamarin.com/show_bug.cgi?id=44994#c2.
2016-11-03 10:29:51 +00:00
Zoltan Varga 241c64c46f [runtime] Fix the exception message to include the proper type name and calling assembly when Type.GetType () fails. Fix some warnings. (#3876) 2016-11-02 22:58:27 -04:00
Aleksey Kliger (λgeek) f2448c8a85 Merge pull request #3868 from lambdageek/c9-42584-take4
[C9][custom attr] Add low-level metadata iterator for assembly custom attributes

And use it to check for the reference assembly attribute.

Using the low level APIs means we don't trigger load of referenced
assemblies and we don't need to take locks, so it is safe to call this
during assembly loading.

Follow-up work for https://bugzilla.xamarin.com/show_bug.cgi?id=42584
2016-11-02 14:52:40 -04:00
Marek Safar a2d8263be9 [mcs] Remove unknown warnings reporting to match latest csc 2016-11-02 17:03:15 +01:00
Zoltan Varga e8f4c7c216 [runtime] Fix the build. 2016-11-02 03:24:24 -04:00
Zoltan Varga 9129faee43 [arm] Call the tls get trampoline through a GOT slot instead of directly, since a direct call could go through the trampoline code which would fail if the thread is not attached to the runtime. Fixes #45371. (#3850) 2016-11-02 03:24:02 -04:00
Zoltan Varga ffecf56a40 [jit] Simplify the code generation for the mkrefany opcode, the same code can handle the aot and non-aot case. The non-aot case was emitting OP_STOREP_MEMBASE_IMM opcodes with 64 bit immediates, and some platforms like arm64 couldn't handle that. 2016-11-02 03:23:47 -04:00
Zoltan Varga 2b31b6957b [arm] Fix MONO_CONTEXT_GET_CURRENT (), the inline assembly block was using pre-increment addressing instead of post increment. (#3866) 2016-11-02 03:23:35 -04:00
Alexander Köplinger 18f6b64356 [corlib] Map SHA*Cng algorithms to SHA*Managed on monodroid
This is a followup to e9205142b2.
Monodroid is missing the Cng and CryptoServiceProvider variants of the SHA
algorithms as well so we need to map to the Managed variants there too,
like on monotouch.

(cherry picked from commit e796ded61a)
2016-11-02 00:53:04 +01:00
Aleksey Kliger 4e4a87dddb [custom attr] Iterate over methoddef custom attrs
Make mono_assembly_metadata_foreach_custom_attr iterate over
MethodDef custom attributes in addition to MemberRef.
2016-11-01 17:55:17 -04:00
Aleksey Kliger 5396c60248 [loader] treat corlib same as other assemblies when checking ReferenceAssemblyAttribute
Now that we're using a metadata-only ReferenceAssemblyAttribute check,
we can treat corlib the same as any other assembly - if we see
ReferenceAssemblyAttribute when loading a candidate assembly, skip it.
2016-11-01 17:55:16 -04:00
Aleksey Kliger 7ece22c72f [custom-attrs] Add low-level metadata iterator for assembly custom attributes
And use it to check for the reference assembly attribute.

Using the low level APIs means we don't trigger load of referenced
assemblies and we don't need to take locks, so it is safe to call this
during assembly loading.
2016-11-01 17:55:15 -04:00
Zoltan Varga c44892d7d4 [runtime] Perform the reference assembly attribute check using the low level metadata apis outside of a lock. 2016-11-01 17:54:38 -04:00
Aleksey Kliger (λgeek) c42036b51b Merge pull request #3788 from lambdageek/c9-42584-take2
[C9] Check for ReferenceAssemblyAttribute when loading for execution
2016-10-31 10:16:48 -04:00
Marek Safar b153e1d93d [corlib] SharedStatics from referencesource. Fixes #46175 2016-10-31 12:57:30 +01:00
Alexander Köplinger 2a8afac254 [System] Fix monodroid build when BTLS is disabled 2016-10-31 02:25:54 +01:00
Miguel de Icaza 244124e617 Backport to 4.8.0 of mkbundle SDK + native library support (#3834)
This backports the mkbundle support that allows mkbundle to use complete SDKs, as opposed to a single runtime to bundle packages as completing the native library loading support.

* [mkbundle] - Add support for bundling native libraries.

* [mkbundle] add support for bundling native libraries

* [glib] add g_mkdtemp

* mono: Load the various library payloads for bundled executables

* [msvc] Export mono_dl_open and mono_loader_register_module

* [scripts] Add script to package the basic runtime to reuse by mkbundle

* [mkbundle] Add diagnostics, fix crash, fix registered path to match runtime name on embedded MonoImages (#3669)
2016-10-30 10:07:15 -04:00
Alexander Köplinger e51aa0a704 Merge pull request #3848 from rolfbjarne/btls-remove-unused-pinvokes-4.8
[System] Remove unused BTLS P/Invokes.
2016-10-28 16:03:49 +02:00
Alexander Köplinger 03e08ac9b5 [bcl] Disable BTLS on xammac and xammac_net_4_5 profiles
(cherry picked from commit 4c8069a5e1)
2016-10-28 15:59:39 +02:00
Alexander Köplinger d8e83dff76 [btls] Fix library install
We need to ensure the directory is created and doesn't have an extraneous '/' char.

(cherry picked from commit d1555df244)
2016-10-28 15:57:52 +02:00
Zoltan Varga d38b7ffedd [btls] Install the btls shared library on make install. (#3825)
(cherry picked from commit 2b09b5fd6b)
2016-10-28 15:57:01 +02:00
Rolf Bjarne Kvinge 7c0ec405fc [System] Remove unused BTLS P/Invokes.
They point to internal functions that don't exist, causing compilation
problems for Xamarin.Mac apps.

Example test/compile failure: https://gist.github.com/rolfbjarne/43cf2228816bbe8a863f331da3e07c0d
2016-10-28 08:19:20 +02:00
Aleksey Kliger a06e82f6c0 [coop handles] Don't scan null object references
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=45223
2016-10-27 16:12:46 -04:00
Martin Baulig 43558a209d [bcl]: Fix 'Mono.Btls.Interface' build logic. 2016-10-27 17:04:12 +02:00
Alexander Köplinger bc72a85bea Merge pull request #3830 from rolfbjarne/watchos-fix-defaultproxy-test-4.8
[System] Tweak define to exclude System.Net.WebProxy.CreateDefaultProxy and update corresponding test.
2016-10-27 00:32:31 +02:00
Rolf Bjarne Kvinge 16b8979fd1 [System] Tweak define to exclude System.Net.WebProxy.CreateDefaultProxy and update corresponding test. 2016-10-26 20:36:19 +02:00
Zoltan Varga 8b8d4c41d2 [llvm] Use the global llvm context instead of creating a new one for each aot module, since the latter seems to cause random memory corruption/crashes. 2016-10-26 14:09:58 -04:00
Ludovic Henry 8864f4c6e9 [threadpool-ms] Fix race condition on domain unload (#3592)
This race condition has been introduced with 348d793ebb. This is because we would wait on the cleanup_semaphore outside of the threadpool->domains_lock lock.

By using a cond variable instead of a semaphore, we avoid a potential deadlock.
2016-10-25 22:12:57 -04:00
Alexander Köplinger 5807bf100a [bcl] Only build Mono.Btls.Interface and btls tool when BTLS is enabled
(cherry picked from commit 3c26e4e5b9)
2016-10-25 22:34:13 +02:00
Alexander Köplinger 78619b1580 [System] Don't build managed BTLS code on monotouch
After 2fb07d6c6d BTLS can be used as a shared lib,
but this caused an issue in some monotouch tools which grepped the P/Invokes for `__Internal`
since these icalls wouldn't resolve on monotouch since BTLS is disabled there.

Instead, we now completely leave out building the managed parts of BTLS when
BTLS is not enabled.

(cherry picked from commit db21455da9)
2016-10-25 22:33:55 +02:00
Martin Baulig 9fa2060ae2 Bump boringssl. 2016-10-25 17:42:19 +02:00
Marek Safar 5c8fb06829 Merge pull request #3813 from rolfbjarne/watchos-no-cfnetwork-4.8
[System] Remove any CFNetwork usage from the watchOS profile. Fixes #45847.
2016-10-25 16:18:32 +02:00
Martin Baulig c9a67ffc5a [BTLS]: Fix a ref-counting leak in X509ChainImplBtls. Fixes #45687. (#3811)
* [BTLS]: Fix a ref-counting leak in X509ChainImplBtls.  Fixes #45687.

* Set 'untrusted = null' in Dispose().
2016-10-25 15:42:08 +02:00
Marek Safar 6ec4d74fb7 Fixes commit 24a439d9b7 2016-10-25 14:51:05 +02:00
Rolf Bjarne Kvinge c023b2b30a [System] Remove any CFNetwork usage from the watchOS profile. Fixes #45847.
The MacProxy class uses CFNetwork, but since CFNetwork is not a public
framework on watchOS, we can't use it.

So remove MacProxy completely (it only contains internal classes), and throw
PlatformNotSupportedException in any API that used it (the managed networking
stack is not supported on watchOS anyway, so this should be safe).

https://bugzilla.xamarin.com/show_bug.cgi?id=45847
2016-10-24 19:54:42 +02:00
Aleksey Kliger 6a0acd9a03 [tests] Missing custom attr on an assembly should not crash mono. 2016-10-24 13:37:08 -04:00
Alexander Köplinger 9f4abcc38a [bcl] Move a few types from the Facades into the framework for netstandard20 compatibility
See https://github.com/dotnet/standard/pull/76.

Also moved IncrementalHash from System.Core.dll to mscorlib.dll as per discussion with Wes.

(cherry picked from commit adcc481705)
2016-10-24 16:44:19 +02:00
Zoltan Varga 085b653a74 [btls] Convert BTLS icalls to pinvokes by invoking them using [DllImp… (#3799)
* [btls] Convert BTLS icalls to pinvokes by invoking them using [DllImport("__Internal")], which will make it easier to redirect them to a separate dylib in the future.

* [btls] Add a --enable-dynamic-btls configure flag to enable compiling btls into a separate shared library instead of embedding it into the runtime.
2016-10-21 22:12:35 -04:00
Zoltan Varga a2ebdcf9de [runtime] Fix the native-to-managed marshalling of null blittable arrays. Fixes #45788. 2016-10-21 22:12:26 -04:00
Aleksey Kliger 482548a503 [loader] Set image assembly before reference attribute assembly check.
In mono_assembly_load_from_full, the call to
mono_assembly_has_reference_assembly_attribute has to come after
image->assembly is set.  This is because image->assembly->base_dir is
used for probing for referenced assemblies, and the reference assembly
attribute check will probe for assemblies referenced by the custom
attributes on the assembly in image being loaded.
2016-10-21 10:03:20 -04:00
Aleksey Kliger 90c3eb80e7 [loader] Write fully-qualified field names in mono_field_resolve_type errors. 2016-10-21 10:03:12 -04:00
Aleksey Kliger 012d17c539 [custom_attrs] Don't return NULL if a single custom attr is missing.
Add 'ignore_missing' argument to mono_custom_attrs_from_index_checked:
if it is TRUE, a single custom attribute constructor that can't be
resolved to a MonoMethod won't cause the whole method to return NULL.
if 'ignore_missing' is FALSE, use existing behavior.

Updated all the call sites to pass FALSE, except
mono_custom_attrs_from_assembly_checked which also gets a new
'ignore_missing' arg.

Updated 'mono_assembly_has_reference_assembly_attribute to pass TRUE for
ignore_missing.
2016-10-21 09:53:27 -04:00
Aleksey Kliger 036d1c8deb [loader] Disable mono_assembly_has_reference_assembly_attribute
It relies on mono_custom_attrs_from_assembly_checked which is not
sufficiently robust to missing assemblies when trying to look for custom
attributes.
2016-10-21 09:53:26 -04:00
Martin Baulig 4917a53814 [System]: Distinguish between empty hostnames and no hostnames for certificate validation.
SecPolicyCreateSSL() distinguishes between an empty string (validation will fail
if the certificate contains host name constraints) and a null pointer (no host name
checking will be performed) for the hostname.

We incorrectly used `string.IsNullOrEmpty (host)` in a few places.

(cherry picked from commit 00f252d01f)
2016-10-20 19:00:37 +02:00
Martin Baulig a63e7484e0 [System]: ChainValidationHelper: always set 'status11' on error.
(cherry picked from commit 7fdd730928)
2016-10-20 19:00:29 +02:00
Martin Baulig e41ab19f36 [boringssl]: Merge latest chromium-stable branch from Google.
(cherry picked from commit 9a073a2929)
2016-10-20 19:00:21 +02:00
Aleksey Kliger 9c54615875 [runtime] Check for ReferenceAssemblyAttribute when loading for execution.
An assembly with a System.Runtime.CompilerServices.ReferenceAssemblyAttribute
may be loaded in a reflection-only context, but not for execution.

When loading assembly refs, or when loading assemblies by name (as
opposed to file path), a reference assembly will be skipped over and
other assemblies from the GAC and the load path will be tried.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42584
2016-10-18 16:21:04 -04:00
Aleksey Kliger 279597ca63 [loader] Tests for RefereceAssemblyAttribute support
This reverts commit 8612b548ee.

Which itself reverted commit 31de4df835.
2016-10-18 16:19:47 -04:00
Aleksey Kliger 953a8cb68d [runtime] Let mono_custom_attrs_has_attr ignore malformed attributes 2016-10-18 16:19:01 -04:00
Aleksey Kliger 17814af191 [runtime] Don't build temporary array in mono_custom_attrs_get_attr_checked
Just return the first matching attribute as soon as it's found, don't
build a temporary array and then index into it.
2016-10-18 16:19:01 -04:00
Aleksey Kliger 52925e9fd0 [runtime] Mark mono_custom_attrs_get_attr external only
Runtime should use mono_custom_attrs_get_attr_checked.
2016-10-18 16:19:00 -04:00
Aleksey Kliger f40ef277f6 [runtime] Add assembly name to message in FileNotFoundException
when using mono_error_set_assembly_load_simple ()
2016-10-18 16:18:59 -04:00
Zoltan Varga 8be6ecc66f [runtime] Avoid freeing IMT thunks, some threads might still be executing them. This creates a memory leak, but its bounded. Fixes #39832. (#3767) 2016-10-18 14:12:34 -04:00
Alexander Köplinger c101a34944 Bump boringssl submodule 2016-10-18 19:34:26 +02:00
Marek Safar 24a439d9b7 [System] Implements Socket::ConnectAsync. Fixes #44406 2016-10-18 17:44:40 +02:00
Marek Safar 412e531404 Bump cecil to get recent fixes 2016-10-18 14:16:55 +02:00
Marek Habersack 1db9061145 With Android 7.0 (Nougat) it is no longer possible to read some
information about network interfaces from the /sys filesystem. Google
placed restrictions on two files used by the Mono BCL to read
information about the interface:

      /sys/class/net/[DEVICE]/flags
      /sys/class/net/[DEVICE]/operstate

The information we used to read from `flags` let us determine whether
the interface supports multicast and the `operstate` file provided us
with detailed information on the current device state.

Additionally, it is now impossible to read the hardware MAC address used
by any interface. This bit of information is also unavailable when using
the Java APIs and therefore applications running on devices with API
24 (and possibly newer) will not be able to access this information.

More details about the issue are available from the upstream Android
bug:

      https://code.google.com/p/android/issues/detail?id=205565

In order to obtain the required information, we now need to use the Java
APIs on devices with API 24+ and this commit implements the backend to
retrieve this information. It is done in C in order to avoid overhead of
creating mirror .NET objects when calling Java, thus saving time and
memory during an operation which may be performed by some applications
quite frequently.

This patch implements code that calls into the Xamarin.Android
runtime when runnin under API24 or newer to obtain the information.

Part of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=44296
2016-10-17 23:58:45 +02:00
Marek Safar 27210fe3dd Merge pull request #3770 from slluis/fix-RSACertificateExtensions
Implemented System.Security.Cryptography.X509Certificates.RSACertific…
2016-10-17 17:12:11 +02:00
Marius Ungureanu b7a0a48637 Grab a new build 2016-10-17 11:39:50 +03:00
Alexander Köplinger d6fdb0187f [System] Fix expected default value in test for ServicePointManager.ConnectionLimit on XA
The default was aligned with XI on https://github.com/mono/mono/commit/d06354174070d01394f5e75ffcfc9c1110a1e7db

(cherry picked from commit dcf4ddd097)
2016-10-15 01:09:56 +02:00
Alex Rønne Petersen c7ed10cd30 Merge pull request #3774 from alexrp/main-thread-name-c9
[4.8.0][runtime] Don't change the native name of the main thread.
2016-10-14 23:16:19 +02:00
Rodrigo Kumpera fa6fba7f8b Merge pull request #3768 from kumpera/backport-machine-config-fixes
Backport of the machine config fixes for remoting.
2016-10-14 12:46:16 -04:00
Alex Rønne Petersen a9abf98848 [runtime] Don't change the native name of the main thread.
This makes it hard to differentiate multiple Mono processes in `top`.

We still report the name of the main thread as "Main" to the profiler.
2016-10-14 18:25:47 +02:00
Alexander Köplinger d6aba05c4d [System.ServiceModel] Move a few types into System.IdentityModel
They were moved there in MS.NET 4.5. Added typeforwards so existing references continue to work.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=35662

(cherry picked from commit 34f6aab87e)
2016-10-14 16:18:18 +02:00
Lluis Sanchez d4e09f5c35 Implement some missing methods in RSACryptoServiceProvider 2016-10-14 15:27:31 +02:00
Lluis Sanchez 04a376b2ab Implemented System.Security.Cryptography.X509Certificates.RSACertificateExtensions 2016-10-14 09:27:08 +02:00
Marek Safar f15d5eb557 [System.Xml] Update supported time formats for mobile version of XML deserializer. Fixes #42843 2016-10-14 09:10:54 +02:00
Rodrigo Kumpera bdf32af198 [icalls] Multiple fixes to get_bundled_machine_config.
Enviroment::get_bundled_machine_config icall should be ves_icall_System_Environment_get_bundled_machine_config.

Mark all icalls doing get_bundled_machine_config as ICALL_EXPORT so maccore can link them in/out.
2016-10-13 13:16:43 -07:00
Rodrigo Kumpera 4fbcd0a817 [corlib] RemotingConfiguration now try to use the bundled machine.config first. 2016-10-13 13:15:43 -07:00
Rodrigo Kumpera 2613ab4063 [corlib] Don't load the machine config file if it's missing. Fixes #44707 2016-10-13 13:15:36 -07:00
Alexander Köplinger bd1dc2169c [System] Add tests for IPv6-enabled FtpWebRequest
(cherry picked from commit d91796e39c)
2016-10-13 20:32:41 +02:00
Alexander Köplinger da5839ee45 [System] Add IPv6 support to FtpWebRequest
When connecting to an FTP server we weren't handling the RFC2428
extension to the FTP protocol which allows connections over IPv6
for the data channel.

We'd try to connect via IPv4 and the server would return an error
saying that this protocol is not supported.

The fix is to add handling for the protocol extension, namely
to use EPSV (for passive FTP) or EPRT (for active FTP) when opening
the data channel and send/parse the IPv6 addresses.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44025

Note: we're now using the IP address of the the control channel we connected to for the
data channel instead of the address that is returned by the server in the FTP response message.
The reason is that for EPSV there's no IP returned by the server, and it should be
more reliable for normal PASV as well since the server might not know the
correct external address. This is also what MS does in referencesource.

(cherry picked from commit aebed51257)
2016-10-13 20:32:33 +02:00
Alexander Köplinger 4865590736 [System] Make sure FtpWebRequest processing happens in a background thread
We don't want it to block app shutdown.

(cherry picked from commit 26f23dbde3)
2016-10-13 20:32:26 +02:00
Marek Safar 6e8bb472af [System] SocketAsyncEventArgs::Dispose does not free any managed resources. Fixes #44757 2016-10-13 16:46:07 +02:00
Martin Baulig 90699022b6 [System]: Move MonoBtlsProvider.IsSupported() -> MonoTlsProviderFactory.IsBtlsSupported() (#3760)
* [System]: Move MonoBtlsProvider.IsSupported() -> MonoTlsProviderFactory.IsBtlsSupported().

Move the intern-call which is used to determine whether we're using BTLS out of MonoBtlsProvider
to allow the managed linker to eliminate the Mono.Btls.* classes when it's not supported.

* Fix Android build.
2016-10-13 16:26:40 +02:00
Rodrigo Kumpera f07d3d7f1d [System] Another round of hardening around disposal of Process while doing async reads.
This round ensures stream and decoder are protected from dispose and that we properly
bail out to the EOS case.
2016-10-12 11:17:03 -07:00
Bernhard Urban 0e6db9e499 [coop] fix compiliation issue on ARM 2016-10-12 17:47:39 +02:00
Marek Safar 6d39b0c188 [mcs] Handle interpolated strings with escaped quotes. Fixes #45286 2016-10-12 17:35:08 +02:00
Marek Safar 97588a349d Bump ikvm for mcs fixes 2016-10-12 15:52:17 +02:00
Marek Safar 5cbb67c54c [Mono.Data.Sqlite] Regression introduced by 04162ffbbd which changed _datetimeFormats order. Fixes #40603 2016-10-12 12:07:23 +02:00
Zoltan Varga c84d659693 [llvm] Avoid generating invalid IL for valuetypes+vphi+volatile variables in gsharedvt methods. Fixes part of #45270. 2016-10-11 16:04:37 -04:00
Zoltan Varga 1085ce7424 [llvm] Make sure the initlocals_bb is not treated as part of a try block if one starts at IL offset 0, since it could mess up the control flow if it contains calls. (#3718) 2016-10-11 16:04:30 -04:00
Martin Baulig 46379bda6d [cert-sync]: Change back to using the '--btls' argument.
Without arguments, 'cert-sync' now operates on the old certificate store
again, like it was before.  To test BTLS, you need to explicitly run it
with '--btls'.
2016-10-11 18:13:14 +02:00
Alexander Köplinger dca5ff953f [io-layer] Correctly detect a PE32+ assembly as managed when starting process
We weren't checking whether a PE file is in PE32 or PE32+ format,
causing us to use the PE32 offsets on the newer format as well.

This means that using Process.Start() on a managed assembly didn't
always work when a PE32+ file was in play. Such a file is created
when targeting x64 e.g. via the -platform:x64 csc.exe/mcs option.

The reason why we probably didn't notice until now is that in an
assembly produced by mcs there happens to be some data at the PE32
CLR header offset even in a PE32+ file, causing the check to "work".

This doesn't apply to csc.exe/roslyn though and so we couldn't
execute those assemblies via Process.Start() even though they're
perfectly managed. Since the .NET Core project.json toolchain
produces x64-targeted assemblies by default more people ran into
the issue trying to run those on Mono: https://github.com/cake-build/cake/issues/1247

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44937

PE/COFF spec at https://msdn.microsoft.com/en-us/library/windows/desktop/ms680547(v=vs.85).aspx

(cherry picked from commit 68bcbb4b77)
2016-10-11 17:28:37 +02:00
Marek Safar 8594aa3456 [System] Set more error details on failed https proxy connect. Fixes #45108 2016-10-11 14:25:49 +02:00
Alan McGovern 79baed228a Trigger a build
Includes the fix for

https://bugzilla.xamarin.com/show_bug.cgi?id=45232
2016-10-11 11:43:42 +01:00
Zoltan Varga 4fde35fdfb [runtime] Fix the blittable flag and the instance size for pointer types. Fixes #45131. (#3735) 2016-10-10 17:48:21 -04:00
Alexander Köplinger de6a46ee3c [corlib] Add missing constructors to RNGCryptoServiceProvider on monotouch
Those were missed in cb46f78eef because there's a separate
implementation for monotouch in an unrelated file.

(cherry picked from commit dac829dbe9)
2016-10-10 20:14:41 +02:00
Martin Baulig 1ac809aad7 [System]: Fix a typo in X500DistinguishedName.AreEqual(). 2016-10-10 18:29:27 +02:00
Alexander Köplinger b77e7ab021 [btls] Use UTC for the Unix epoch in the managed BTLS code (#3702)
The epoch is specified as being in UTC, but the DateTime(int, int, int) constructor
creates a DateTime with an 'Unspecified' timezone, which could lead to problems later on.
(cherry picked from commit 8d1a65128a)
2016-10-10 18:04:28 +02:00
Martin Baulig 1a55680bfa [BTLS]: Correctly handle certificates with negative serial numbers. (#3719)
In mono_btls_x509_get_serial_number(), first call i2c_ASN1_INTEGER()
which takes care of padding and computing the 2s complement for negative
numbers, then reverse the buffer.
2016-10-10 18:02:26 +02:00
Marek Safar 0865083699 [System.Data] Use same socket family for data receiver as it has its client. Fixes #44624 2016-10-10 16:25:43 +02:00
Alexander Köplinger cd557f4992 [corlib] Add CLSComplaint(false) to a few EventSource methods
We did it in master already, those are needed so the generated
library source in dotnet/standard builds out of the box.
2016-10-10 15:17:05 +02:00
Alexander Köplinger 4a3b9d4bce [bcl] Expose a few more APIs on mobile to match with netstandard
See https://github.com/dotnet/standard/issues/47.

(cherry picked from commit cb46f78eef)
2016-10-10 13:39:58 +02:00
Alex Rønne Petersen e897a5d7e4 Merge pull request #3743 from alexrp/profiler-c9-fixes-4.8
[4.8.0][profiler] Start the helper thread before the writer thread.
2016-10-08 13:23:16 +02:00
Alex Rønne Petersen 4919fb1938 [profiler] Start the helper thread before the writer thread.
This fixes a regression introduced in 0db428169a
which caused the profiler to not report the correct command port in the file
header on startup.
2016-10-08 11:56:45 +02:00
Aleksey Kliger (λgeek) 9bd0647bba Merge pull request #3733 from lambdageek/c9-bug-42271
[C9][coop] Switch to GC SAFE for backtrace() and backtrace_symbols()
2016-10-07 13:14:17 -04:00
Rodrigo Kumpera bd34946f14 Merge pull request #3724 from kumpera/fix_process_stream_dispose-backport
Fix process stream dispose backport
2016-10-07 13:11:27 -04:00
Marek Safar 9c029cc9cd [System] Use default parsing rules for Uri.IsWellFormedUriString. Fixes #45129 2016-10-07 13:56:57 +02:00
Aleksey Kliger f41c45460f [runtime] System.Configuration.InternalConfigurationHost:get_bundled_machine_config
needs HANDLES

The method (which also goes by
System.Configuration.DefaultConfig:get_bundled_machine_config) was
converted to use coop handles earlier, but we missed this declaration.
2016-10-06 21:22:27 -04:00
Rodrigo Kumpera e066377aea [System] Add some hardening when disposing a AsyncStreamReader as it will have things happening concurrently. 2016-10-06 15:53:53 -07:00
Aleksey Kliger d28e482915 [mempool] Fix indentation in mono_backtrace () 2016-10-06 12:25:39 -04:00
Aleksey Kliger ecbbb82986 [coop] Switch to GC SAFE for backtrace() and backtrace_symbols()
Fixes [#42271](https://bugzilla.xamarin.com/show_bug.cgi?id=42271)
2016-10-06 12:25:12 -04:00
Rodrigo Kumpera ead28ef4ed [System] Dispose all streams in Process::Close if they were not exposed to the user. Fixes a RS import regression.
RS takes the stance that redirected streams should not be closed by the Process class because they might
be referenced from the outside.

That would be ok if it was true. If you use Process::BeginOutputReadLine, the output stream becomes inaccessible
with no way to dispose them by any mean but GC.Collect. You get an exception when accessing Process::StandardOutput
once async reading starts.

This change addresses the case where the streams are not accessible. This is tracked by the *StreamReadMode variables
that are set on stream getters or Begin*ReadLine.
2016-10-05 14:55:45 -07:00
Rodrigo Kumpera d1a58bc9bb [runtime] Don't do logging from a signal handler. It's not signal safe.
I found this while trying to MONO_LOG_LEVEL=debug an process way bug and the removed log statements
would hang mono in a matter of seconds.
2016-10-05 14:55:42 -07:00
Marek Safar 951f3c8837 [System.Net.Http] Wrap certain exceptions into HttpRequestException. Fixes #44978 2016-10-05 17:57:20 +02:00
Marek Safar ba04892f92 [mcs] Don't report version mismatch error for FX assemblies 2016-10-05 15:03:14 +02:00
Alexander Köplinger fb01e0742c Merge pull request #3708 from rolfbjarne/linker-mark-nested-types-4.8.0
[linker] We need to mark nested types even if the declaring type isn't marked.
2016-10-05 13:50:49 +02:00
Alexander Köplinger 960ae16ebc [ci] Correctly set the MONO_TLS_PROVIDER env var 2016-10-05 13:13:10 +02:00
Martin Baulig 9638ee9ece [BTLS]: Certificate cleanups and fixes. (#3706)
* [BTLS]: Allow fallback to MX.X509Certificate in X509CertificateImplBtls.

* [BTLS]: Fix X509Certificate2.MonoCertificate.

* X509Certificate2Impl.FallbackImpl: make abstract.

* X509Helper2.GetMonoCertificate(): new internal helper method.

* X509Certificate2.MonoCertificate: use X509Helper2.GetMonoCertificate().
  This is only used by X509ChainImplMono; we should investigate whether we
  could implement the missing APIs in BTLS.

* [BTLS]: Fully implement X509CertificateImplBtls.Import() and use correct semantics.

.NET's X509Certificate2.Import() uses several implicit fallbacks which we previously
did not handle in BTLS.

* you may provide a (unused) password when importing an unencrypted PKCS#8.

* when using null as password, it will attempt to use string.Empty if importing
  without password fails.

* [BTLS]: Implement X509CertificateImplBtls.PrivateKey.

* [BTLS]: Implement X509CertificateImplBtls.Export().

* [BTLS]: Implement X509CertificateImplBtls.Verify().

* [BTLS]: Fix X500DistinguishedName quoting.

* MonoBtlsUtils: don't quote special chars in UTF-16 strings.

* X500DistinguishedName: don't decode raw data when passed in a name.

* [ci] Test System.dll with both the legacy and btls TLS provider

* [ci] Only run the additional btls System.dll test run on OSX for now

Otherwise we might run it on platforms where btls isn't supported yet and get errors.
2016-10-05 13:05:24 +02:00
Cinerar 1b234b0667 Nowdays Content-Range From could be much more than 2147483647 2016-10-05 10:19:05 +02:00
Aleksey Kliger 6209317c15 [MonoError] Don't overwrite computed TypeLoadException message with empty string
Fixes [#44729](https://bugzilla.xamarin.com/show_bug.cgi?id=44729).
2016-10-04 17:24:26 -04:00
Rolf Bjarne Kvinge 3090df7136 [linker] We don't need to mark nested types more than once. 2016-10-04 18:53:00 +02:00
Alexander Köplinger 08c6cb22b7 Merge pull request #3694 from rolfbjarne/watchos-simplify-http-message-handler-selection-4.8.0
[System.Net.Http] Simplify default http message handler for watchOS since there's only one valid value.
2016-10-04 18:39:41 +02:00
Alexander Köplinger e66a9c7086 Merge pull request #3703 from rolfbjarne/watchos-servicepointmanager-4.8.0
[System] Add back a few ServicePointManager properties that can be used by multiple networking stacks.
2016-10-04 18:35:54 +02:00
Rolf Bjarne Kvinge de8c6e6e42 [linker] We need to mark nested types even if the declaring type isn't marked. 2016-10-04 16:38:08 +02:00
Rolf Bjarne Kvinge 0851acb468 [System] Add back a few ServicePointManager properties that can be used by multiple networking stacks. 2016-10-04 10:37:45 +02:00
Alex Rønne Petersen 9bcb1f5081 Merge pull request #3701 from alexrp/profiler-c9-fixes-4.8
[4.8.0][profiler] Fix a regression that caused all buffers to have a zero thread ID.
2016-10-04 04:58:42 +02:00
Alex Rønne Petersen 815b3b210a [profiler] Use macro constants instead of passing a bunch of bools. 2016-10-04 04:55:50 +02:00
Alex Rønne Petersen 4e283b76d2 [profiler] Update a stale comment. 2016-10-04 04:08:59 +02:00
Alex Rønne Petersen 33670c335f [profiler] Add some asserts. 2016-10-04 04:08:54 +02:00
Alex Rønne Petersen 18bea6c1c0 [profiler] Simplify send_log_unsafe (). 2016-10-04 04:08:50 +02:00
Alex Rønne Petersen 50fdd4483d [profiler] Fix a regression that caused all buffers to have a zero thread ID.
This was introduced in 928b840dad.
2016-10-04 04:08:38 +02:00
Alexander Köplinger 1598ce194b [btls] Add missing icall definition for mono_btls_x509_revoked_get_revocation_date
(cherry picked from commit 65c849b377)
2016-10-04 02:40:01 +02:00
Alex Rønne Petersen 5f612a6044 Merge pull request #3699 from alexrp/profiler-c9-fixes
[4.8.0] More C9 profiler fixes
2016-10-04 00:15:42 +02:00
Alex Rønne Petersen fa98e7cc3b [profiler] Fix BYTE_SIZE macro conflict on OS X. 2016-10-04 00:11:18 +02:00
Alex Rønne Petersen fad0111583 [profiler] Fix PROF_TLS_FREE () on pthread TLS systems. 2016-10-04 00:11:12 +02:00
Rodrigo Kumpera b1d68b0200 [profiler] Fix the build on Android (missing fcntl.h include). 2016-10-04 00:11:07 +02:00
Martin Baulig 7b2a96fbd3 [metadata]: Unconditionally enable ves_icall_Mono_Btls_Provider_IsSupported().
The MonoBtlsProvider.IsSupported() icalls ves_icall_Mono_Btls_Provider_IsSupported()
needs to be available whether BTLS is available or not because it is used at
runtime to decide whether or not to enable BTLS.
2016-10-03 22:01:31 +02:00
Martin Baulig 04379d5d73 Oops, actually correctly revert that commit. 2016-10-03 21:21:36 +02:00
Martin Baulig cd1b0b8edf [System]: Temporarily switch the default TLS provider back to "legacy".
Also revert the Jenkins commit in c462f4e603.
2016-10-03 21:13:19 +02:00
Rolf Bjarne Kvinge 81b800cf0c [System.Net.Http] Simplify default http message handler for watchOS since there's only one valid value. 2016-10-03 18:24:47 +02:00
Alexander Köplinger c462f4e603 [ci] Temporarily switch back to legacy TLS provider
(cherry picked from commit 993f805cb7)
2016-10-03 17:11:33 +02:00
Alexander Köplinger f9b5ea2d04 Merge branch 'watchos-ssl-4.8.0' into mono-4.8.0-branch 2016-10-03 13:13:36 +02:00
Rolf Bjarne Kvinge 053458ce22 [System] Update tests after API change for watchOS. 2016-10-03 13:11:46 +02:00
Rolf Bjarne Kvinge 40bd0c0bce [System] Throw PlatformNotSupportedExceptions in the networking stack for watchOS. 2016-10-03 13:11:45 +02:00
Rolf Bjarne Kvinge efaeebcb60 [System.Data] Update tests after API change in watchOS. 2016-10-03 13:08:12 +02:00
Rolf Bjarne Kvinge c09e0d9ee5 [System.Data] System.Data.SqlClient is not supported in watchOS.
System.Data.SqlClient is not supported in watchOS, because it depends on a
working managed networking stack, which we don't have on watchOS.
2016-10-03 13:08:11 +02:00
Rolf Bjarne Kvinge d99a0d5382 [System] Don't reference/build Mono.Security.dll when building for watchOS.
This means we can't build Mono.Data.Tds.dll either, since it uses
Mono.Security.dll extensively. In any case Mono.Data.Tds.dll is useless
without a working networking stack, and since it's a Mono-only dll (i.e. not
part of netstandard or facades), just remove the entire assembly from the
watchOS profile.

System.Security.dll uses Mono.Security.dll as well, but the required classes
are available inside mscorlib.dll (as internal classes), so just open up
mscorlib internals to System.Security.dll.
2016-10-03 13:08:10 +02:00
Alexander Köplinger a1b9700735 [btls] Fix i386 build on Linux by setting -arch on Darwin only
The -arch option is an Apple extension, it caused failures on i386 Linux: "unrecognized command line option '-arch'"

(cherry picked from commit aad01ff4db)
2016-10-03 00:34:08 +02:00
Alex Rønne Petersen 613fbda594 Merge pull request #3690 from alexrp/mono-4.8.0-branch
[4.8.0] Profiler fixes for C9
2016-10-02 22:36:10 +02:00
Alex Rønne Petersen 6efdbf52f1 [profiler] Fix GC finalize object end event not getting invoked. 2016-10-02 22:33:23 +02:00
Alex Rønne Petersen a32cff4490 Revert "[domain] Report domain unloads to the profiler when finalizing the domain."
This reverts commit c8b2029080.

This caused ordering problems with app domain events: https://bugzilla.xamarin.com/show_bug.cgi?id=44552

Conflicts:

	mono/metadata/gc.c
2016-10-02 22:33:21 +02:00
Alex Rønne Petersen a13a0a6764 [profiler] Build fix for 4.8.0. 2016-10-02 22:25:59 +02:00
Alex Rønne Petersen aa5012088e [profiler] Bump profiler version to v1.1. 2016-10-02 22:23:53 +02:00
Alex Rønne Petersen 3bba08400b [profiler] Don't emit enter/leave events in onlycoverage mode. 2016-10-02 22:23:52 +02:00
Alex Rønne Petersen dc6448964a [profiler] Add a nocounters option. 2016-10-02 22:23:51 +02:00
Alex Rønne Petersen 0e0b1537db [profiler] Address a couple of FIXMEs in the counters sampling code. 2016-10-02 22:23:51 +02:00
Alex Rønne Petersen 9259c0d43b [profiler] Use eglib alloc/free functions everywhere. 2016-10-02 22:23:50 +02:00
Alex Rønne Petersen 3af315a5f8 [profiler] Warn if we can't detect the CPU count. 2016-10-02 22:23:50 +02:00
Alex Rønne Petersen 27e89dadba [profiler] Use the native thread wrapper functions to manage threads. 2016-10-02 22:23:49 +02:00
Alex Rønne Petersen 323c660694 [utils/threads] Add and export a mono_native_thread_join () function. 2016-10-02 22:23:48 +02:00
Alex Rønne Petersen 6d68435660 [utils/threads] Export all native thread functions. 2016-10-02 22:23:48 +02:00
Alex Rønne Petersen 4b18517404 [profiler] Access in_shutdown atomically. 2016-10-02 22:23:47 +02:00
Alex Rønne Petersen ee6bfbb041 [profiler] Drop support for perf events on Linux. 2016-10-02 22:23:47 +02:00
Alex Rønne Petersen 00a04f8feb [utils/lfa] Add a missing #include to fix the profiler build. 2016-10-02 22:23:46 +02:00
Alex Rønne Petersen 84fb54be56 [profiler] Disable GC move events when allocation events are disabled.
They serve no purpose when allocation profiling is enabled, and just make log
files bigger than they have to be.
2016-10-02 22:23:45 +02:00
Alex Rønne Petersen 70db685357 [profiler] Clean up and improve the helper thread code.
* Don't invoke undefined behavior if an fd is >= FD_SETSIZE.
* Allow multiple command sockets.
* Close the command socket(s) on shutdown.
* Properly run cleanup logic on shutdown.
2016-10-02 22:23:45 +02:00
Alex Rønne Petersen fa7a3ddc9b [profiler] Process requests in method_jitted (). 2016-10-02 22:23:44 +02:00
Alex Rønne Petersen c910d330c3 [profiler] Remove the need to pass a MonoProfiler argument to some functions.
This is now available on the MonoProfilerThread structure.
2016-10-02 22:23:44 +02:00
Alex Rønne Petersen 36662ae5c8 [profiler] Fix the way the profiler frees hazardous data on shutdown. 2016-10-02 22:23:43 +02:00
Alex Rønne Petersen e614f44499 [profiler] Replace a check with an assert in coverage_filter (). 2016-10-02 22:23:43 +02:00
Alex Rønne Petersen 5bfd110124 [profiler] Add messages to most assertions. 2016-10-02 22:23:42 +02:00
Alex Rønne Petersen 8340747664 [profiler] Remove the ign_res () hack. 2016-10-02 22:23:41 +02:00
Alex Rønne Petersen 60fc6c5649 [profiler] Clean up the #include mess in mono-profiler-log.c.
Half of these aren't even needed - get rid of those. Sort the rest.
2016-10-02 22:23:41 +02:00
Alex Rønne Petersen 9f5247c4b3 [profiler] Remove mono_threads_attach_tools_thread () declaration.
We get this from mono-threads.h now.
2016-10-02 22:23:40 +02:00
Alex Rønne Petersen 30633ffd58 [profiler] Remove some broken, commented-out code from register_method_local (). 2016-10-02 22:23:40 +02:00
Alex Rønne Petersen 3a1da6e5c9 [profiler] assert () -> g_assert (). 2016-10-02 22:23:39 +02:00
Alex Rønne Petersen 9014c62f06 [profiler] Always enable the helper thread.
We need it in all cases now that we use it to periodically flush all buffers.
The only platforms it was disabled on was NaCl, which we haven't bothered to
support in a while anyway.
2016-10-02 22:23:38 +02:00
Alex Rønne Petersen 17c2e47270 [profiler] Encapsulate some common logic in the ENTER_LOG/EXIT_LOG macros.
This also has the nice effect of reducing the amount of times we attempt to
take the reader lock. Now we take it and release it once for a single event.
2016-10-02 22:23:38 +02:00
Alex Rønne Petersen 7c8d6480e0 [profiler] Add a missing deinit_thread () call to the helper thread. 2016-10-02 22:23:37 +02:00
Alex Rønne Petersen 5d0406ce13 [profiler] Fix several race conditions in accessing MonoProfilerThread.buffer.
Only in very few situations is it okay to access this field without first
taking the reader lock or exclusive lock.

Fixes some crashes observed in the profiler stress tests.
2016-10-02 22:23:37 +02:00
Alex Rønne Petersen 43babda1a0 [profiler] Don't flush empty log buffers. 2016-10-02 22:23:36 +02:00
Alex Rønne Petersen cac2b2402e [profiler] Add an extra assert. 2016-10-02 22:23:36 +02:00
Alex Rønne Petersen 3e22fd4852 [sgen] Always report object moves on the GC thread.
This avoids exposing the SGen worker threads through the profiler APIs. Doing
so had two main problems:

* It's easy for a user of the profiler API to accidentally mess with the state
  of the worker thread in all sorts of ways, which could break the GC.
* It's been a long-standing guarantee that any profiler API callback will be
  invoked on a thread that is, at the very least, attached to the runtime via
  the mono-threads infrastructure. This is not the case for SGen workers.

This fixes a deadlock in the log profiler when using major=marksweep-conc.
2016-10-02 22:23:35 +02:00
Alex Rønne Petersen e1b914a97f [profiler] Rename decode.c to mprof-report.c. 2016-10-02 22:23:34 +02:00
Alex Rønne Petersen f5f92d5d39 [profiler] Rename proflog.{c,h} to mono-profiler-log.{c,h} for consistency with other profilers. 2016-10-02 22:23:34 +02:00
Alex Rønne Petersen 99342a6654 [profiler] Remove utils.c/utils.h, move the code to proflog.c/decode.c, and clean it up.
* Drop support for fast/null timers.
* Use Mono runtime functions for getting the thread ID and allocating buffers.
2016-10-02 22:23:33 +02:00
Alex Rønne Petersen c4e7de38d5 [acceptance-tests] Improve the profiler-stress test runner.
* Emit an NUnit test report file.
* Set a timeout of 6 hours per test.
* Do a thread dump for timed-out tests.
* Don't print stdout/stderr for passing tests.
2016-10-02 22:23:33 +02:00
Alex Rønne Petersen 1f533cf45b [ci] Bump the timeout of the profiler stress test suite to 24 hours. 2016-10-02 22:23:32 +02:00
Alex Rønne Petersen 3ecb96bc26 [sgen] Remove bogus mono_profiler_events assert.
This variable can be changed at any time by any thread. It makes no sense to
assert that it has a particular flag.
2016-10-02 22:23:32 +02:00
Alex Rønne Petersen 818fd2a032 [utils] Move MONO_DEPRECATED to mono-publib.h and make it imply MONO_API + MONO_RT_EXTERNAL_ONLY.
Also make it work with MSVC.
2016-10-02 22:23:31 +02:00
Alex Rønne Petersen b2b6a6effa [profiler] Remove the long-obsolete hsmode option.
Also refactor the heap walk code a bit.
2016-10-02 22:23:31 +02:00
Alex Rønne Petersen 510399644b [profiler] Document and fix the onlycoverage option. 2016-10-02 22:23:30 +02:00
Alex Rønne Petersen 60fdc682f1 [profiler] Remove the countersonly option.
It was never documented and is no longer functional.
2016-10-02 22:23:29 +02:00
Alex Rønne Petersen 9167d1def0 [man] Update mprof-report.1 to indicate the correct default maxframes value. 2016-10-02 22:23:29 +02:00
Alex Rønne Petersen 96e2b7d9ea [profiler] Use the signal shutdown logic for the sampling thread for more cases. 2016-10-02 22:23:28 +02:00
Alex Rønne Petersen d5ab942572 [profiler] Remove some indirection in setting up GC events.
* mono_gc_enable_events: This did nothing for SGen and we called it
  unconditionally for Boehm. So no point in having it around.
* mono_gc_enable_alloc_events: The performance difference between checking
  a static alloc_events variable versus checking mono_profiler_events is
  marginal at best and doesn't justify the indirection, especially now that
  we support managed allocators while profiling.
2016-10-02 22:23:28 +02:00
Alex Rønne Petersen 2849de826a [profiler] Lift profiler limitation in mono_class_get_allocation_ftn ().
This has not actually been necessary since allocation reporting was moved into
the GC implementations.
2016-10-02 22:23:27 +02:00
Alex Rønne Petersen 074e535380 [profiler] Don't leak counter data structures on shutdown. 2016-10-02 22:23:27 +02:00
Alex Rønne Petersen f9f1147466 [profiler] Simplify counters initialization. 2016-10-02 22:23:26 +02:00
Alex Rønne Petersen 3f46eb6b06 [profiler] Don't emit a perf counters sample event if none are registered. 2016-10-02 22:23:26 +02:00
Alex Rønne Petersen 099ddf1b78 [profiler] Fix the code that synthesizes thread end events.
It could previously fail to process a newly allocated buffer.
2016-10-02 22:23:25 +02:00
Alex Rønne Petersen cf30f6102c [profiler] Add counters for all event types. 2016-10-02 22:23:24 +02:00
Vlad Brezae c03c5c8e5a [runtime] Replace uses of alloc functions with glib variants 2016-10-02 22:23:22 +02:00
Zoltan Varga bf6cffb88e [runtime] Pass the initial context to mono_walk_stack_with_ctx () in mono_stack_walk_async_safe (). Hopefully fixes #44164. 2016-10-02 22:22:49 +02:00
Alexander Köplinger dd7e330373 [btls] Fix bashism in create-object-library.sh
Found by checkbashisms(1) as "unsafe echo with backslash". Some shells don't expand embedded \n in a string by default,
which broke the build on systems like ArchLinux or Alpine where /bin/sh points to those shells because the generated .lo
file contained just a single line instead of two.

Thanks to @JustArchi for researching this on the Mono Gitter channel, it made fixing the issue a lot easier!

(cherry picked from commit 1958bb8b34)
2016-10-02 17:16:18 +02:00
Martin Baulig 7c88bf755e Put back the MonoBtlsContext.cs change that I accidentally reverted. 2016-10-01 21:32:16 +02:00
Martin Baulig 4d28eb4b88 [System]: ChainValidationHelper: ignore port number when validating a certificate's host name. 2016-10-01 21:30:36 +02:00
Martin Baulig baebc1d8c0 [BTLS]: Ignore port number when validating certificates. 2016-10-01 21:20:29 +02:00
Martin Baulig 2602c52de4 [BTLS]: Send server name extension on the client. 2016-10-01 21:20:29 +02:00
Alexander Köplinger deac4585cb Fix build break from 81fb20737f
The HttpWebResponse stub that is used e.g. on the monotouch_watch profile was missing an overload that this commit was using.

(cherry picked from commit f4475ff013)
2016-10-01 02:58:51 +02:00
Marek Safar f04a619165 [System] Fill more WebException details when CONNECT fails. Fixes #19594 2016-10-01 00:11:57 +02:00
Martin Baulig 30fabaedd3 [scripts]: Add 'btls-cert-sync' script. 2016-09-30 22:50:39 +02:00
Martin Baulig 7002264dd2 [System]: Fix MonoTlsProviderFactory.TryDynamicLoad() logic.
If the MONO_TLS_PROVIDER environment variable is missing, use "default".
2016-09-30 22:45:30 +02:00
Martin Baulig b894d5ce4a [System]: Make BTLS the default TLS Provider on Desktop.
(cherry picked from commit 069a1e4f78)
2016-09-30 17:37:22 +02:00
Martin Baulig 9827f491f0 [cert-sync]: Make the new store the default and add '--legacy' for the old one.
(cherry picked from commit ecdc3ef482)
2016-09-30 17:30:36 +02:00
Martin Baulig b39ff26269 [BTLS]: Remove some debugging methods.
(cherry picked from commit aa320774ed)
2016-09-30 17:12:51 +02:00
Alexander Köplinger f0f53513f3 Merge pull request #3680 from rolfbjarne/fix-monotouch-build-4.8.0
[System] Fix monotouch* build.
2016-09-30 17:03:08 +02:00
Martin Baulig e81c051ab3 [System]: Enable AndroidPlatform.CertStoreLookup().
Uses reflection to call into AndroidEnvironment.CertStoreLookup()
(which as been added in https://github.com/xamarin/xamarin-android/pull/246).

(cherry picked from commit 0b045d2b6e)
2016-09-30 16:27:20 +02:00
Rolf Bjarne Kvinge 90d6fc7082 [System] Fix monotouch* build. 2016-09-30 16:23:23 +02:00
Alexander Köplinger 36ffc29d19 Bump boringssl to fix the build
(cherry picked from commit 2417bf1861)
2016-09-30 16:14:41 +02:00
Alexander Köplinger ec7374048f [btls] Only use cmake policies CMP0026/CMP0042 if cmake supports it
Some older cmake versions don't.

(cherry picked from commit bd1d7650ec)
2016-09-30 15:58:31 +02:00
Martin Baulig 9e46b5744b [System]: AndroidPlatform.CertStoreLookup(): add to the build, but return null.
This needs to have support added to xamarin-android before we can enable it.
2016-09-30 15:17:34 +02:00
Chris Hamons 6392e1746f Add Mono.Runtime to XM 4.5 profile
- Extends https://github.com/mono/mono/pull/3624

(cherry picked from commit 0c64f16bcb)
2016-09-30 14:57:45 +02:00
Martin Baulig a71f2b45c6 [BTLS]: Add managed BTLS sources.
* external/boringssl: unmanaged code from Google (added earlier).

* mono/btls: unmanaged BTLS lives here (added earlier).

* System/Mono.Btls: managed BTLS lives here.

* Mono.Btls.Interface: The purpose of this assembly is to allow test suites
  such as xamarin/web-tests to test parts of the BTLS APIs without making
  System.dll's internals visible.  It is not a stable and maintained API.

(cherry picked from commit 0f8f0c543c)
2016-09-30 14:21:08 +02:00
Martin Baulig 07fc3dc95b [Mono.Security]: Add the new certificate store.
BTLS uses a different format and naming scheme for the local certificate store.

Before using BTLS for the first time on desktop, you need to convert the local
certificate store by either using the new `btls-cert-sync` tool (which will convert
your existing certificate store to the new new format) or `cert-sync` with the
`--btls` argument.

The new format and naming scheme is identically to what you'll find in
'/system/etc/security/cacerts/' on an Android device.  It stores the certificates
in PEM format (with a human-readable text section added) using filenames which
are based on the certificate's subject name hash.

Previously, Mono stored the certificates in binary DER format, using a filename
based on either the Subject-Key-Identifier (if available) or the thumbprint.

We cannot access this from BTLS because computing these filenames requires
reading the entire X509 certificate (including the X509v3 extensions), but
their native lookup code only gives us the SubjectName.

This transitioning won't affect Android users as we're using the system
certificate store (including the user certificate store, via a Java callback).

* Mono.Security.X509.X509Store and X509Stores:
  Support both the old and the new format.  Using the new format requires BTLS.

* Mono.Security.X509.X509StoreManager:
  Add `NewCurrentUserPath` and `NewLocalMachinePath` properties for the
  new path names (~/.config/.mono/new-certs).

* Mono.Security.X509.X509StoreManager:
  Add `NewCurrentUser` and `NewLocalMachine` properties.  Requires BTLS.

* tools/security/cert-sync:
  Add new `--btls` argument to use the new store.

(cherry picked from commit fb93be4490)
2016-09-30 13:39:24 +02:00
Martin Baulig c5c809d6dc [System]: Add AndroidPlatform.CertStoreLookup().
This is conditional to HAVE_BTLS and needs to have support added
to xamarin-android first.

(cherry picked from commit 52b290680c)
2016-09-30 13:04:45 +02:00
Martin Baulig 334d0f84d9 [System]: New X509Helper2 APIs for BTLS.
The managed HAVE_BTLS conditionals will be removed once BTLS itself has landed.

(cherry picked from commit d88ce91459)
2016-09-30 13:04:45 +02:00
Marek Safar 4cbb1922c3 [System.Data] Implements SqlClient async readers. Fixes #44843 2016-09-30 12:09:38 +02:00
Martin Baulig b4b21d081b [BTLS]: Add the native BTLS sources.
(cherry picked from commit c950be01ac)
2016-09-30 11:48:18 +02:00
Martin Baulig 63c0803b2b [Mono.Security]: Cleanup the MonoTlsProvider's certificate validation code. (#3674)
* [Mono.Security]: Remove Mono.Security.Interface.IMonoTlsContext.

This interface is not actually used anywhere anymore, so we can also
just get rid of it.

* [System]: Removed unused private TLS classes.

* [Mono.Security]: Cleanup the MonoTlsProvider's certificate validation code.

Each TLS Provider now has its own certificate validator and there is no
automatic fallback anymore.  We only have three different TLS Providers,
"legacy", "appletls" and "btls" - and legacy is the only one which used
the managed validator.  Both AppleTls and BTLS provider their own validator,
which invokes some native API.

All of the following were internal APIs.

* MonoTlsProvider.HasCustomSystemCertificateValidator has been removed.

* MonoTlsProvider.InvokeSystemCertificateValidator() has been renamed
  into ValidateCertificate() and is now abstract.
2016-09-29 22:47:28 +02:00
Marek Safar fc6b2d359d [mcs] Branch visited labels cache for conditional block. Fixes #44751 2016-09-29 22:40:22 +02:00
Alexander Köplinger 8f689a60fe Merge pull request #3672 from rolfbjarne/pr-fix-system-tests-4.8
[System] Fix tests that regressed in e6536dd.
2016-09-29 15:00:52 +02:00
Rolf Bjarne Kvinge 5f174dd217 [System] Fix tests that regressed in e6536dd.
* I got confused between [TestFixtureSetup] and [Setup], so fix tests whose
  [Setup] methods were changed/removed to properly clean up after each test
  (using a [TearDown] method) so that the next time the on-demand creation of
  objects works as expected (i.e. objects created in the [Setup] method should
  be created on-demand once for each method instead of once for each class).

* Also fix SocketAcceptAsyncTest, the change to properly catch exceptions on
  background threads was incorrect.
2016-09-29 13:56:26 +02:00
Rodrigo Kumpera 5e454f9c20 [logging] Fix logging on iOS. We lost asl redirection and it was sending to stdout instead. 2016-09-28 17:08:53 -07:00
Martin Baulig 1935a43f60 [configure] Add configure.ac checks for BTLS. (#3668)
(cherry picked from commit 1055069416)
2016-09-29 01:11:32 +02:00
Martin Baulig 9437553e54 [System]: Rename MonoLegacyTlsProvider into LegacyTlsProvider. (#3666)
LegacyTlsProvider now lives in the 'Mono.Net.Security' namespace
(previously 'Mono.Net.Security.Private') and derives directly from
the public 'Mono.Security.Interface.MonoTlsProvider'.

This allows it to be used by products, for instance replacing
xamarin-macios/src/Security/Tls/OldTlsProvider.cs.

The idea is to have all 'MonoTlsProvider' implementations inside
System.dll and not access any of the private APIs from outside of it.
2016-09-29 00:53:03 +02:00
Marek Safar 01dcbdd3fc [corlib] Improve test added in 54ea12e4fa 2016-09-29 00:29:49 +02:00
Rolf Bjarne Kvinge aaaead4d5b [corlib] Add API to uninstall/reinstall signal handlers.
This API is provided to be used by libraries providing crash reporting, so
that those libraries can install signal handlers and at the same time not
interfere with Mono's signals.

The intended pattern is this:

    Mono.Runtime.RemoveSignalHandlers ();
    InstallThirdPartySignalHandlers ();
    Mono.Runtime.InstallSignalHandlers ();

This ensures that Mono is always notified first of any signals, and will then
chain to the third-party signal handlers if the signal did not originate in
managed code.

Mono's signals must first be removed, so that if third-party signal handler
does signal chaining, we don't end up in Mono's signal handler again.

Mailing-list thread: http://lists.dot.net/pipermail/macios-devel/2016-September/000016.html [Signal-chaining & crash reporters]
Example usage: https://github.com/rolfbjarne/HockeySDK-Xamarin/commit/862721199f1adec210bfc7b1943f975ffb8048a9
2016-09-28 19:47:02 +02:00
Rolf Bjarne Kvinge f2ff1683aa [mini] Provide a free function to the saved signal handler hash table.
This makes the cleanup code simpler, and also makes it easier to
replace saved signal handlers without having to worry about
leaking memory.
2016-09-28 19:47:02 +02:00
Marek Safar c5e917ca96 [System] Reduce duration of SendGenericExceedBuffer test 2016-09-28 18:13:11 +02:00
Aleksey Kliger 18ae0d10fc [runtime] Fix MonoMethod.get_base_method when abstract methods are not overridden
When there is an abstract class in the middle of an inheritance
hierarchy that doesn't override a method, get_base_methods needs to search
the parent class instead aborting early.

Example:

```
abstract class Root {
  public abstract void Foo ();
}
abstract class Abs : Root { }
class Derived : Abs {
  public override void Foo () { }
}
```

If we ask for the base method of Derived.Foo we used to get Derived.Foo
back because Abs did not provide an override.  Instead we should skip
abs and look in Root.
2016-09-28 11:02:59 -04:00
Aleksey Kliger 662513e62b [coop handles] Add some memory fences
When running with async suspend (ie, not coop), a user thread might be
suspended while its manipulating the coop handle stack.  In that case,
we want to present a consitent view to mono_handle_stack_scan () by
adding memory fences to code that updates the stack chunks.  In
particular we want to ensure that the chunk size is increased after
the new slot has a valid (null) value.  Also when creating new chunks
make sure their size is initialized before the chunk stack is updated.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43921 (at least the
one stack trace observed in [comment 1](https://bugzilla.xamarin.com/show_bug.cgi?id=43921#c1)).
2016-09-28 10:18:14 -04:00
Ludovic Henry 37b8dc4fab [w32handle] Ensure we initialize begore the gc attach the current thread (#3648) 2016-09-28 16:04:09 +02:00
Martin Baulig 0d07c695b5 [System]: Cleanup the internal MobileTlsContext.
* Add SelectClientCertificate().
* ValidateCertificate() now returns bool.
* Add ValidateCertificate() overload.
2016-09-28 13:39:47 +02:00
Martin Baulig fcc570920d [Mono.Security]: Cleanup the internal ICertificateValidator2. 2016-09-28 13:39:37 +02:00
Martin Baulig c155563d1e Remove all MONO_FEATURE_NEW_TLS conditionals. 2016-09-28 13:39:30 +02:00
Martin Baulig 5b412212cd Cleanup; with the removal of 'PrebuiltSystemAlias', we don't need to use XX509* anymore. 2016-09-28 13:39:22 +02:00
Martin Baulig c2e7ca6c99 [System]: Make Test/System.Net.Sockets compile. 2016-09-28 13:36:03 +02:00
Martin Baulig 7c3ae83b31 [Mono.Security.Interface] Cleanup and simplify MonoTlsProviderFactory.
The "global" TLS Provider (returned by MonoTlsProviderFactory.GetProvider())
may only be modified at application startup (before any of the TLS / Certificate
code has been used).

* MonoTlsProviderFactory.HasProvider has been removed.

  This property used to initialize the TLS Subsystem without throwing any
  exceptions.  However, properties with side-effects is a bad design principle.

* Add MonoTlsProviderFactory.IsInitialized.

  Does not have any side-effects.

* Add MonoTlsProviderFactory.Initialize() and Initialize(string).

  May only be called at application startup and explicitly initializes the
  TLS Subsystem.

* Rename MonoTlsProviderFactory.GetDefaultProvider() into GetProvider()
  and removed MonoTlsProviderFactory.GetCurrentProvider().

  We do not distinguish between a "default" and a "current" provider anymore;
  there is only one "global" provider.

* Add MonoTlsProviderFactory.IsProviderSupported(string).

  Checks whether a specific TLS Provider is supported, without having side-effects.

* Make the old APIs [Obsolete] until products have been updated.

* Add some documentation to MonoTlsProviderFactory.
2016-09-27 22:21:13 +02:00
Rolf Bjarne Kvinge ddf9f2359d [System*] Throw a PlatformNotSupported exception when using the networking stack on watchOS. (#3655)
* [System] Fix line endings for a few files.

Best reviewed by not showing whitespace changes (should be empty diff in that case).

* [System] Fix potential crash in CookieParserTests.

Socket.EndAccept can throw an exception, which will crash the process if it
happens on a threadpool. So handle any exceptions when calling
Socket.EndAccept, and propagate those exceptions out of any threadpool code.

* [System.Net.Http] Throw a PlatformNotSupported exception when using HttpClientHandler on watchOS.

* [System.Net.Http] Tweak tests after watchOS API change.

Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.

* [System] Extract the HttpListenerResponseHelper class to a separate file.

Extract the HttpListenerResponseHelper class to a separate file so that it's
easier to replace the HttpListenerResponse implementation by using a different
file.

* [System] Throw a PlatformNotSupported exception when using the networking stack on watchOS.

* [System] Tweak tests after watchOS API changes.

Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.

* [System] Fix potential crash in SocketAcceptAsyncTest.

Fix potential crash in SocketAcceptAsyncTest by catching any exceptions in
code executed on the threadpool so that we never end up with unhandled
exceptions (which may terminate the process).

* [System] Avoid logic in SetUp attributes in tests.

Any type of exception in [SetUp] attributes causes all tests to fail with that
exception.

This even happens for tests that do not need the logic in the [SetUp]
attribute.

So rewrite tests a bit to not use [SetUp] when we can reasonably avoid it, and
instead instantiate class-level variables on first use. This ensures that any
exceptions that occur when initializing those variables are attributed to the
corresponding test, and not all of them.

* [System] Make exception handler (for test) catch more exceptions to avoid unhandled exceptions causing process termination.

* [System] Remove Obsolete attribute on API that throws PNSE.
2016-09-27 21:15:11 +02:00
Marek Habersack 88a98e08c1 Fix trace logging on Android
Introduction of the structured trace logger accidentally broke Android
logcat logging. The reason for this is that the default logging handler
defined in eglib (in goutput.c) for Android was never called, instead it
was superseeded by the log file logger defined in mono-logger.c

The net effect was that Mono tried to write the messages to some file on
Android leaving logcat devoid of any trace of life :)

This commit fixes the issue by introducing a set of structured logging
functions for Android.

As a side note - file logging on Android is not that useful. Writing to
a file on external storage medium requires app permissions and writing
to a location on internal storage medium, while allowed, might be
subject to space limitations and should not be used for possibly
voluminous data. It's therefore not very practical on Android.
2016-09-27 20:35:47 +02:00
Martin Baulig fc99fc4313 [Mono.Security]: Cleanup Mono.Security.Interface.CertificateValidationHelper.
* CertificateValidationHelper.GetDefaultValidator(): rename this internal method into
  GetInternalValidator() (keeping the old as [Obsolete] until products have been updated).

* CertificateValidationHelper.GetValidator(): remove the 'provider' argument.

This is part of a set of cleanups and simplifications for the upcoming BTLS integration.

(cherry picked from commit 61d76d9642)
2016-09-27 11:40:44 +02:00
Marek Safar 84fbbb8de7 [System] Fixes SendGenericExceedBuffer test 2016-09-26 20:47:01 +02:00
Marek Safar c162180aee [System] netstandard compatible Process collections 2016-09-26 16:58:32 +02:00
Zoltan Varga 18235dfff1 [jit] Resurrect the Monitor.Enter () v4 optimization. (#3632) 2016-09-25 18:41:49 -04:00
Alexander Köplinger 5381bdc290 [System] Add ISupportInitialize on mobile FileSystemWatcher
The interface was missing on the mobile stub.

(cherry picked from commit 4d325a0674)
2016-09-25 14:00:47 +02:00
Alexander Köplinger 1c40419bc7 [System] Remove obsolete HttpWebRequest/Response constructors again
They were removed from a later revision of netstandard2.0 so we don't need to add them.

(cherry picked from commit 566f0a78b0)
2016-09-25 13:03:35 +02:00
Alex Earl 529502bf41 Fix issue with VB projects
Fixed GenerateFullPathToTool for Vbc task to match behavior of the Csc
task. This allows VB.NET projects to build successfully.

See https://bugzilla.xamarin.com/show_bug.cgi?id=44714

(cherry picked from commit d6bb144980)
2016-09-25 01:55:29 +02:00
Martin Baulig 2a3e4002ea [AppleTls]: Flush the write queue before finishing the handshake.
It is possible for SSLHandshake() to return SslStatus.Success while we're still
having a pending write (AsyncOperationStatus.WantWrite).

This is because our managed write callback must never return 'WouldBlock', so
SSLHandshake() things that all data have been sent while we still have them in
our write queue.

When this happens, we currently flush the write queue then call SSLHandshake()
again via AsyncOperationStatus.WantWrite -> AsyncOperationStatus.Continue.

This returns SslStatus.Protocol on iOS 10.

(cherry picked from commit 2cc1b887c1)
2016-09-24 07:38:35 +02:00
Zoltan Varga 5c2d1761e9 [llvm] Add static rgctx trampolines to array access methods in the aot+llvm case too. (#3616) 2016-09-23 17:40:43 -04:00
Martin Baulig f3bd113611 Fix mono/tests/Makefile.am (blank line after trailing backslash). 2016-09-23 18:20:48 +02:00
Alexander Köplinger 58bf33a539 [bcl] Add missing APIs for netstandard parity and expose a few APIs on mobile
This ensures we're compliant with the upcoming netstandard2.0 API surface area.

(cherry picked from commit 112631f5c6)
2016-09-23 17:58:04 +02:00
Alexander Köplinger feeeb1cd3f [bcl] Add CLSComplaint(false) to a few types/methods that aren't compliant
(cherry picked from commit fa986f1e36)
2016-09-23 17:57:56 +02:00
Alexander Köplinger 64ce52fa6a [System.Core] Expose a few more System.IO.Pipes APIs on mobile
Required for netstandard matching.

(cherry picked from commit f5836956c6)
2016-09-23 17:57:27 +02:00
Zoltan Varga 3ab4fe29ab Revert "[loader] Tests for RefereceAssemblyAttribute support"
This reverts commit 31de4df835.

Revert this as the corresponding fix was reverted.
2016-09-23 10:11:10 -04:00
Marek Safar 9208eb2070 [corcompare] More hacks to make breaking change not too disruptive 2016-09-23 14:45:04 +02:00
Marek Safar 610984e83b [bcl] Base type update to match netstandard apis 2016-09-23 12:19:39 +02:00
Zoltan Varga b591e86c1a [arm64] Handle thunks with ARM64_B relocations as well. 2016-09-22 19:30:18 -04:00
Marek Safar 81822428e9 Merge pull request #3603 from ninjarobot/socket-write
Send all data to a socket before exit from Socket.Send.
2016-09-22 23:14:20 +02:00
Marek Safar 210801836e [corcompare] Another try to make breaking change not too discruptive 2016-09-22 20:12:16 +02:00
Marek Safar 25d7170248 Add missing file 2016-09-22 14:46:43 +02:00
Marek Safar 6f075050c2 [colrib] Fixes aecdb91a06 and add GC tests 2016-09-22 14:46:25 +02:00
Marek Safar 7a87a23651 [corcompare] Drop ParameterAttributes from method signature 2016-09-22 12:27:42 +02:00
Martin Baulig f2558db1a7 [runtime]: Move "_ReRegisterForFinalize" in icall-def.h.
Fixes the sort order to make the warnings go away.
2016-09-22 08:10:34 +02:00
Martin Baulig 0bafe8c3c7 [Mono.Security]: Add 'MonoTlsConnectionInfo.PeerDomainName'. 2016-09-22 07:38:09 +02:00
Martin Baulig 7b7b7c9b64 Remove obsolete Mono.Security.Providers.* assemblies (#3595)
* Remove Mono.Security.Providers.NewSystemSource and Mono.Security.Providers.NewTls.

* Remove InternalVisible for "Xamarin.BoringTls".

* Remove Mono.Security.Providers.OldTls and Mono.Security.Providers.DotNet.
2016-09-22 07:20:00 +02:00
Zoltan Varga 94acdcf647 [runtime] Fix the managed name of the ReRegisterForFinalize () icall. 2016-09-21 17:52:25 -04:00
Marek Safar 5da8cfe05d [mcs] Add compilergenerated attribute for private event backing fields to match newer csc 2016-09-21 12:55:05 +02:00
Henric Müller 95744eb659 Only set NoDelay by default for protocol TCP
(cherry picked from commit cd40eb318e)
2016-09-21 11:38:17 +02:00
Alexander Köplinger c05627e24b [Facades] Another define fix
It was missed in https://github.com/mono/mono/commit/c84760250884989e10d707c049fd0aacae79c93e.
2016-09-21 09:00:25 +02:00
Marek Safar 4044840804 [Facades] Use correct define 2016-09-21 09:00:25 +02:00
Alan McGovern f484d0d9c0 Bump to pull in a new gtk with this build 2016-09-20 18:24:06 -04:00
Alexander Köplinger 6a5c925b65 Fix Linux build break due to case sensitivity
(cherry picked from commit de8a76a1c1)
2016-09-20 20:07:48 +02:00
Marek Safar 7919e9abf8 [System] Add more types to mobile profile 2016-09-20 17:56:08 +02:00
Marek Safar 1f03b3ff35 [corlib] GC from referencesource 2016-09-20 17:29:38 +02:00
Alexander Köplinger 158a79950a Merge pull request #3581 from radical/mcs-ignore-args
[mcs] Accept and ignore command line args supported by csc that we don't
2016-09-19 18:11:19 +02:00
Ankit Jain 52bb524f49 [mcs] Accept and ignore command line args supported by csc that we don't
.. support:

	/publicsign+
	/publicsign-
2016-09-19 12:08:26 -04:00
Marek Safar 919b89954a [bcl] Add more reflection types to monotouch 2016-09-19 16:58:39 +02:00
Katharina Bogad 475c58eaff [System.Web] HttpCookie load defaults from Web.config
HttpCookie now loads default values from the Web.config,
just like the reference source does.
2016-09-19 16:53:40 +02:00
Marek Safar 6387e9c6d0 [mcs] Fixes codegen of predefined pointer arithmetic operators with user defined operator conversion for one of operands. Fixes #44440 2016-09-19 16:52:42 +02:00
Marek Habersack af086b0c70 [mkbundle] support satellite assemblies (#3448)
Satellite assemblies are special in that they all share the same file
name, but they live in separate directories named after the locale the
satellite assemblies pack. mkbundle currently doesn't support "clashing"
assembly filenames and will not be able to store the satellite
assemblies in the bundle for that reason.

This patch adds support for storing satellite assemblies with their
culture path prefix (e.g. en-US/MyAssembly.resources.dll) in the bundle
and also special code in the assembly loader to support such filenames
in the code which loads assemblies from the bundle.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=27061
2016-09-19 12:32:51 +02:00
Vlad Brezae d341594fac [jit] Fix missing wbarrier for array generic setter
The generic setter receives the element by reference which means we will never emit the write barrier since a reference to a reference is not a reference (mini_type_is_reference). Check the actual value instead. Fixes #42903.
2016-09-16 20:47:09 +03:00
Marek Safar 45bde6931d [corlib] Add missing apis 2016-09-16 18:06:30 +02:00
Marek Safar d364710817 [System.Net.Http] Show invalid values added to HttpHeaderValueCollection. to Fixes #44413. 2016-09-16 15:49:10 +02:00
Marek Safar 66f6456e86 [mcs] Delay array base type interfaces initialization. Fixes #44402 2016-09-16 13:14:01 +02:00
Marek Safar 4a3bbf5b42 Merge pull request #3572 from rolfbjarne/tests-system-dns-make-failures-not-crash-app-4.8
[System] Rewrite Dns tests so that failures don't cause the process to crash.
2016-09-16 12:34:36 +02:00
Rolf Bjarne Kvinge 3c2e1c56b2 [System] Rewrite Dns tests so that failures don't cause the process to crash.
Previously the tests were written so that some failures might occur on the
threadpool in methods that did not catch exceptions. In that case the process
would terminate due to an unhandled exception. So rewrite the tests to catch
exceptions in any code that doesn't run on the main thread, and forward those
exceptions to the main thread.

Also wait for async operations to complete on the main thread, and remove
asserts that are not supposed to be hit.

This is a backport of PR #3558.
2016-09-16 11:56:21 +02:00
Marek Safar fee3014cd3 [mcs] Report more errors for nameof expressions. Fixes #44168 2016-09-16 10:58:15 +02:00
Zoltan Varga c1c53bcfca Revert "[runtime] Check for ReferenceAssemblyAttribute when loading for execution."
This reverts commit bc9461168e.

Revert this to see if it fixes the wrench build.
2016-09-15 15:01:57 -04:00
Zoltan Varga 05b93203a5 [winx64] Mark some inline functions static to hopefully fix the mxe build. 2016-09-15 14:07:26 -04:00
Marek Safar 377041fd6e [build] Add System.Numerics.Vectors to xammac profile 2016-09-15 14:18:03 +02:00
Marek Safar 28194f79fe [mcs] Improve member lookup rules when type parameter has both non-object effective base class and interface constraint(s) 2016-09-15 13:40:51 +02:00
Marek Safar 9e16432697 [mcs] Move type constraints checks after base type definition. Fixes #44212 2016-09-14 15:43:09 +02:00
Marek Habersack 482ab094eb Set DefaultPersistentConnectionLimit to 10 for Xamarin.Android
This is to make it the same as the Xamarin.iOS setting and
fixes https://bugzilla.xamarin.com/show_bug.cgi?id=7467
2016-09-14 11:19:35 +02:00
Marek Safar f8a716bf29 [System] Don't compress custom http headers in httplistener response. Fixes #34715 2016-09-13 16:12:03 +02:00
Zoltan Varga 762d337187 Bump version to 4.8.0 2016-09-12 19:30:35 +02:00
618 changed files with 28962 additions and 8749 deletions

No files matched your search

+4
View File
@@ -39,3 +39,7 @@
path = external/cecil-legacy
url = git://github.com/mono/cecil.git
branch = mono-legacy-0.9.5
[submodule "external/boringssl"]
path = external/boringssl
url = git://github.com/mono/boringssl.git
branch = mono
+2 -1
View File
@@ -4,7 +4,8 @@ SYS_REFS = \
System.Data.dll \
System.Runtime.Serialization.dll \
System.Xml.dll \
System.Xml.Linq.dll
System.Xml.Linq.dll \
Mono.Posix.dll
check-profiler-stress:
@$(MAKE) validate-benchmarker RESET_VERSIONS=1
+188 -18
View File
@@ -1,7 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using Mono.Unix.Native;
using Newtonsoft.Json;
// Shut up CLS compliance warnings from Json.NET.
@@ -10,7 +17,8 @@ using Newtonsoft.Json;
namespace Mono.Profiling.Tests.Stress {
// https://github.com/xamarin/benchmarker/blob/master/tools/libdbmodel/Benchmark.cs
class Benchmark {
sealed class Benchmark {
public string Name { get; set; }
public string TestDirectory { get; set; }
public bool OnlyExplicit { get; set; }
@@ -24,8 +32,24 @@ namespace Mono.Profiling.Tests.Stress {
}
}
sealed class TestResult {
public Benchmark Benchmark { get; set; }
public ProcessStartInfo StartInfo { get; set; }
public Stopwatch Stopwatch { get; set; } = new Stopwatch ();
public int? ExitCode { get; set; }
public StringBuilder StandardOutput { get; set; } = new StringBuilder ();
public StringBuilder StandardError { get; set; } = new StringBuilder ();
}
static class Program {
static readonly TimeSpan _timeout = TimeSpan.FromHours (6);
static string FilterInvalidXmlChars (string text) {
return Regex.Replace (text, @"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]", string.Empty);
}
static int Main ()
{
var depDir = Path.Combine ("..", "external", "benchmarker");
@@ -44,8 +68,7 @@ namespace Mono.Profiling.Tests.Stress {
var rand = new Random ();
var cpus = Environment.ProcessorCount;
var successes = 0;
var failures = 0;
var results = new List<TestResult> (benchmarks.Length);
var sw = Stopwatch.StartNew ();
@@ -66,6 +89,8 @@ namespace Mono.Profiling.Tests.Stress {
WorkingDirectory = Path.Combine (testDir, bench.TestDirectory),
FileName = monoPath,
Arguments = $"--debug --profile=log:{profOptions} " + string.Join (" ", bench.CommandLine),
RedirectStandardOutput = true,
RedirectStandardError = true,
};
info.EnvironmentVariables.Clear ();
@@ -77,32 +102,177 @@ namespace Mono.Profiling.Tests.Stress {
Console.WriteLine ($"[{sw.Elapsed.ToString ("G")}] {progress} Running {bench.Name} with profiler options: {profOptions}");
Console.ResetColor ();
var sw2 = Stopwatch.StartNew ();
var result = new TestResult {
Benchmark = bench,
StartInfo = info,
};
using (var proc = Process.Start (info)) {
proc.WaitForExit ();
sw2.Stop ();
using (var proc = new Process ()) {
proc.StartInfo = info;
Console.WriteLine ();
proc.OutputDataReceived += (sender, args) => {
if (args.Data != null)
result.StandardOutput.AppendLine (args.Data);
};
if (proc.ExitCode != 0)
failures++;
else
successes++;
proc.ErrorDataReceived += (sender, args) => {
if (args.Data != null)
result.StandardError.AppendLine (args.Data);
};
Console.ForegroundColor = proc.ExitCode != 0 ? ConsoleColor.Red : ConsoleColor.Green;
Console.WriteLine ($"[{sw.Elapsed.ToString ("G")}] {progress} {bench.Name} took {sw2.Elapsed.ToString ("G")} and exited with code: {proc.ExitCode}");
Console.ResetColor ();
result.Stopwatch.Start ();
proc.Start ();
proc.BeginOutputReadLine ();
proc.BeginErrorReadLine ();
if (!proc.WaitForExit ((int) _timeout.TotalMilliseconds)) {
// Force a thread dump.
Syscall.kill (proc.Id, Signum.SIGQUIT);
Thread.Sleep (1000);
try {
proc.Kill ();
} catch (Exception) {
}
} else
result.ExitCode = proc.ExitCode;
result.Stopwatch.Stop ();
}
var resultStr = result.ExitCode == null ? "timed out" : $"exited with code: {result.ExitCode}";
Console.ForegroundColor = result.ExitCode != 0 ? ConsoleColor.Red : ConsoleColor.Green;
Console.WriteLine ($"[{sw.Elapsed.ToString ("G")}] {progress} {bench.Name} took {result.Stopwatch.Elapsed.ToString ("G")} and {resultStr}");
Console.ResetColor ();
if (result.ExitCode != 0) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine ("===== stdout =====");
Console.ResetColor ();
Console.WriteLine (result.StandardOutput.ToString ());
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine ("===== stderr =====");
Console.ResetColor ();
Console.WriteLine (result.StandardError.ToString ());
}
results.Add (result);
}
sw.Stop ();
Console.ForegroundColor = failures != 0 ? ConsoleColor.Red : ConsoleColor.Green;
Console.WriteLine ($"[{sw.Elapsed.ToString ("G")}] Finished with {successes}/{benchmarks.Length} passing tests");
var successes = results.Count (r => r.ExitCode == 0);
var failures = results.Count (r => r.ExitCode != null && r.ExitCode != 0);
var timeouts = results.Count (r => r.ExitCode == null);
var settings = new XmlWriterSettings {
NewLineOnAttributes = true,
Indent = true,
};
using (var writer = XmlWriter.Create ("TestResult-profiler-stress.xml", settings)) {
writer.WriteStartDocument ();
writer.WriteComment ("This file represents the results of running a test suite");
writer.WriteStartElement ("test-results");
writer.WriteAttributeString ("name", "profiler-stress-tests.dummy");
writer.WriteAttributeString ("total", results.Count.ToString ());
writer.WriteAttributeString ("failures", failures.ToString ());
writer.WriteAttributeString ("not-run", "0");
writer.WriteAttributeString ("date", DateTime.Now.ToString ("yyyy-MM-dd"));
writer.WriteAttributeString ("time", DateTime.Now.ToString ("HH:mm:ss"));
writer.WriteStartElement ("environment");
writer.WriteAttributeString ("nunit-version", "2.4.8.0");
writer.WriteAttributeString ("clr-version", Environment.Version.ToString ());
writer.WriteAttributeString ("os-version", Environment.OSVersion.ToString ());
writer.WriteAttributeString ("platform", Environment.OSVersion.Platform.ToString ());
writer.WriteAttributeString ("cwd", Environment.CurrentDirectory);
writer.WriteAttributeString ("machine-name", Environment.MachineName);
writer.WriteAttributeString ("user", Environment.UserName);
writer.WriteAttributeString ("user-domain", Environment.UserDomainName);
writer.WriteEndElement ();
writer.WriteStartElement ("culture-info");
writer.WriteAttributeString ("current-culture", CultureInfo.CurrentCulture.Name);
writer.WriteAttributeString ("current-uiculture", CultureInfo.CurrentUICulture.Name);
writer.WriteEndElement ();
writer.WriteStartElement ("test-suite");
writer.WriteAttributeString ("name", "profiler-stress-tests.dummy");
writer.WriteAttributeString ("success", (failures + timeouts == 0).ToString ());
writer.WriteAttributeString ("time", ((int) sw.Elapsed.TotalSeconds).ToString ());
writer.WriteAttributeString ("asserts", (failures + timeouts).ToString ());
writer.WriteStartElement ("results");
writer.WriteStartElement ("test-suite");
writer.WriteAttributeString ("name", "MonoTests");
writer.WriteAttributeString ("success", (failures + timeouts == 0).ToString ());
writer.WriteAttributeString ("time", ((int) sw.Elapsed.TotalSeconds).ToString ());
writer.WriteAttributeString ("asserts", (failures + timeouts).ToString ());
writer.WriteStartElement ("results");
writer.WriteStartElement ("test-suite");
writer.WriteAttributeString ("name", "profiler-stress");
writer.WriteAttributeString ("success", (failures + timeouts == 0).ToString ());
writer.WriteAttributeString ("time", ((int) sw.Elapsed.TotalSeconds).ToString ());
writer.WriteAttributeString ("asserts", (failures + timeouts).ToString ());
writer.WriteStartElement ("results");
foreach (var result in results) {
var timeoutStr = result.ExitCode == null ? "_timeout" : string.Empty;
writer.WriteStartElement ("test-case");
writer.WriteAttributeString ("name", $"MonoTests.profiler-stress.{result.Benchmark.Name}{timeoutStr}");
writer.WriteAttributeString ("executed", "True");
writer.WriteAttributeString ("success", (result.ExitCode == 0).ToString ());
writer.WriteAttributeString ("time", ((int) result.Stopwatch.Elapsed.TotalSeconds).ToString ());
writer.WriteAttributeString ("asserts", result.ExitCode == 0 ? "0" : "1");
if (result.ExitCode != 0) {
writer.WriteStartElement ("failure");
writer.WriteStartElement ("message");
writer.WriteCData (FilterInvalidXmlChars (result.StandardOutput.ToString ()));
writer.WriteEndElement ();
writer.WriteStartElement ("stack-trace");
writer.WriteCData (FilterInvalidXmlChars (result.StandardError.ToString ()));
writer.WriteEndElement ();
writer.WriteEndElement ();
}
writer.WriteEndElement ();
}
writer.WriteEndElement ();
writer.WriteEndElement ();
writer.WriteEndElement ();
writer.WriteEndElement ();
writer.WriteEndElement ();
writer.WriteEndElement ();
writer.WriteEndElement ();
writer.WriteEndDocument ();
}
var failureStr = failures + timeouts != 0 ? $" ({failures} failures, {timeouts} timeouts)" : string.Empty;
Console.ForegroundColor = failures + timeouts != 0 ? ConsoleColor.Red : ConsoleColor.Green;
Console.WriteLine ($"[{sw.Elapsed.ToString ("G")}] Finished with {successes}/{results.Count} passing tests{failureStr}");
Console.ResetColor ();
return failures;
return failures + timeouts;
}
}
}
+163 -21
View File
@@ -2,7 +2,7 @@
#AC_PREREQ([2.62])
# when bumping version number below, keep it in sync with man/mono.1 too
AC_INIT(mono, [4.7.0],
AC_INIT(mono, [4.8.0],
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
AC_CONFIG_SRCDIR([README.md])
@@ -52,6 +52,8 @@ CPPFLAGS_FOR_LIBGC=$CPPFLAGS
CFLAGS_FOR_LIBGC=$CFLAGS
CPPFLAGS_FOR_EGLIB=$CPPFLAGS
CFLAGS_FOR_EGLIB=$CFLAGS
CPPFLAGS_FOR_BTLS=$CPPFLAGS
CFLAGS_FOR_BTLS=$CFLAGS
# libgc uses some deprecated APIs
CFLAGS_FOR_LIBGC="$CFLAGS -Wno-deprecated-declarations"
@@ -1156,20 +1158,6 @@ AC_COMPILE_IFELSE([
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for deprecated __attribute__)
AC_TRY_COMPILE([
int doit (void) __attribute__ ((deprecated));
int doit (void) { return 0; }
], [
return 0;
], [
have_deprecated=yes
AC_MSG_RESULT(yes)
], [
have_deprecated=no
AC_MSG_RESULT(no)
])
dnl
dnl Boehm GC configuration
dnl
@@ -2666,12 +2654,6 @@ fi
AC_ARG_ENABLE(bcl-opt, [ --disable-bcl-opt BCL is compiled with no optimizations (allows accurate BCL debugging)], test_bcl_opt=$enableval, test_bcl_opt=yes)
AC_ARG_ENABLE(perf-events, [ --enable-perf-events Enable using `perf` for profiling on Linux], test_perf_events=$enableval, test_perf_events=no)
if test "x$test_perf_events" = "xyes"; then
AC_DEFINE(ENABLE_PERF_EVENTS, 1, [Enable using `perf` for profiling on Linux])
AC_SUBST(ENABLE_PERF_EVENTS)
fi
AC_MSG_CHECKING([if big-arrays are to be enabled])
AC_ARG_ENABLE(big-arrays, [ --enable-big-arrays Enable the allocation and indexing of arrays greater than Int32.MaxValue], enable_big_arrays=$enableval, enable_big_arrays=no)
if test "x$enable_big_arrays" = "xyes" ; then
@@ -2947,6 +2929,8 @@ sizeof_register="SIZEOF_VOID_P"
jit_wanted=true
boehm_supported=true
BTLS_SUPPORTED=no
BTLS_PLATFORM=
case "$host" in
mips*)
TARGET=MIPS;
@@ -2999,9 +2983,13 @@ case "$host" in
;;
linux*)
AOT_SUPPORTED="yes"
BTLS_SUPPORTED=yes
BTLS_PLATFORM=i386
;;
darwin*)
AOT_SUPPORTED="yes"
BTLS_SUPPORTED=yes
BTLS_PLATFORM=i386
;;
openbsd*|freebsd*|kfreebsd-gnu*)
;;
@@ -3017,9 +3005,13 @@ case "$host" in
case $host_os in
linux*)
AOT_SUPPORTED="yes"
BTLS_SUPPORTED=yes
BTLS_PLATFORM=x86_64
;;
darwin*)
AOT_SUPPORTED="yes"
BTLS_SUPPORTED=yes
BTLS_PLATFORM=x86_64
;;
openbsd*|freebsd*|kfreebsd-gnu*)
;;
@@ -3140,6 +3132,7 @@ HOST=$TARGET
if test "x$host" != "x$target"; then
AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
enable_mcs_build=no
BTLS_SUPPORTED=no
case "$target" in
arm*-darwin*)
TARGET=ARM;
@@ -3425,10 +3418,12 @@ if test "x$target_mach" = "xyes"; then
AC_DEFINE(TARGET_WATCHOS,1,[The JIT/AOT targets WatchOS])
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_WATCHOS"
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_WATCHOS"
BTLS_SUPPORTED=no
elif test "x$TARGET" = "xARM" -o "x$TARGET" = "xARM64"; then
AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_IOS"
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_IOS"
BTLS_SUPPORTED=no
else
AC_TRY_COMPILE([#include "TargetConditionals.h"],[
#if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
@@ -3443,6 +3438,7 @@ if test "x$target_mach" = "xyes"; then
AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_IOS"
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_IOS"
BTLS_SUPPORTED=no
])
fi
AC_DEFINE(TARGET_MACH,1,[The JIT/AOT targets Apple platforms])
@@ -3750,6 +3746,45 @@ if test ${TARGET} = unknown; then
AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
fi
if test "x$platform_android" = "xyes"; then
case "x${TARGET}" in
xARM)
case "x$arm_ver" in
xARMv5)
BTLS_SUPPORTED=yes
BTLS_PLATFORM=android-armv5
;;
xARMv6)
BTLS_SUPPORTED=yes
BTLS_PLATFORM=android-armv6
;;
xARMv7)
BTLS_SUPPORTED=yes
BTLS_PLATFORM=android-armv7
;;
*)
BTLS_SUPPORTED=no
;;
esac
;;
xARM64)
BTLS_SUPPORTED=yes
BTLS_PLATFORM=android-v8a
;;
xX86)
BTLS_SUPPORTED=yes
BTLS_PLATFORM=android-x86
;;
xAMD64)
BTLS_SUPPORTED=yes
BTLS_PLATFORM=android-x64
;;
*)
BTLS_SUPPORTED=no
;;
esac
fi
if test ${ACCESS_UNALIGNED} = no; then
CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
fi
@@ -3872,6 +3907,95 @@ else
fi
AC_SUBST(LIBMONO_LA)
dnl **************
dnl *** Btls ***
dnl **************
AC_ARG_ENABLE(btls, [ --disable-blts Disable the BoringTls provider], enable_btls=$enableval, enable_btls=$BTLS_SUPPORTED)
AC_ARG_WITH(btls_android_ndk, [ --with-btls-android-ndk Android NDK for BoringTls])
AC_ARG_ENABLE(dynamic-btls, [ --enable-dynamic-btls Place the BTLS provider into a separate shared library/archive.], enable_dynamic_btls=$enableval, enable_dynamic_btls=no)
AM_CONDITIONAL(BTLS, test x$enable_btls = xyes)
AM_CONDITIONAL(DYNAMIC_BTLS, test x$enable_dynamic_btls = xyes)
btls_android=no
if test "x$enable_btls" = "xyes"; then
AC_PATH_PROG(CMAKE, [cmake], [no], [$PATH:/Applications/CMake.app/Contents/bin:/usr/local/bin])
if test "x$CMAKE" = "xno"; then
AC_MSG_ERROR("cmake not found")
fi
BTLS_ROOT=`cd $srcdir && pwd`/external/boringssl
AC_SUBST(BTLS_ROOT)
btls_arch=
btls_cflags=
BTLS_CMAKE_ARGS=
case "$BTLS_PLATFORM" in
i386)
btls_arch=i386
btls_cflags="-m32"
case $host_os in
darwin*)
btls_cflags="$btls_cflags -arch i386"
esac
;;
x86_64)
btls_arch=x86_64
;;
android-armv5)
BTLS_CMAKE_ARGS="-DANDROID_ABI=\"armeabi\" -DANDROID_NATIVE_API_LEVEL=12"
;;
android-armv6)
BTLS_CMAKE_ARGS="-DANDROID_ABI=\"armeabi\" -DANDROID_NATIVE_API_LEVEL=12"
;;
android-armv7)
BTLS_CMAKE_ARGS="-DANDROID_ABI=\"armeabi-v7a\" -DANDROID_NATIVE_API_LEVEL=12"
;;
android-v8a)
BTLS_CMAKE_ARGS="-DANDROID_ABI=\"arm64-v8a\" -DANDROID_NATIVE_API_LEVEL=12"
;;
android-x86)
BTLS_CMAKE_ARGS="-DANDROID_ABI=\"x86\" -DANDROID_NATIVE_API_LEVEL=12"
;;
android-x64)
BTLS_CMAKE_ARGS="-DANDROID_ABI=\"x86_64\" -DANDROID_NATIVE_API_LEVEL=12"
;;
*)
AC_MSG_ERROR(Invalid BTLS platform)
esac
if test "x$platform_android" = "xyes"; then
btls_android=yes
BTLS_CMAKE_ARGS="$BTLS_CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=$BTLS_ROOT/util/android-cmake/android.toolchain.cmake"
if test "x$with_btls_android_ndk" != "x"; then
BTLS_CMAKE_ARGS="$BTLS_CMAKE_ARGS -DANDROID_NDK=\"$with_btls_android_ndk\""
fi
fi
if test "x$btls_arch" != "x"; then
BTLS_CMAKE_ARGS="$BTLS_CMAKE_ARGS -DBTLS_ARCH=\"$btls_arch\""
fi
BTLS_CFLAGS="$CPPFLAGS_FOR_BTLS $btls_cflags"
AC_SUBST(BTLS_ARCH)
AC_SUBST(BTLS_CFLAGS)
AC_SUBST(BTLS_PLATFORM)
AC_SUBST(BTLS_CMAKE_ARGS)
AC_DEFINE(HAVE_BTLS, 1, [BoringTls is supported])
if test "x$enable_dynamic_btls" = "xyes"; then
AC_DEFINE(HAVE_DYNAMIC_BTLS, 1, [BTLS in a shared libraty])
fi
else
enable_btls=no
fi
AM_CONDITIONAL(BTLS_ANDROID, test x$btls_android = xyes)
if test x$DISABLE_MCS_DOCS = xyes; then
docs_dir=""
else
@@ -4108,6 +4232,7 @@ llvm/Makefile
scripts/mono-find-provides
scripts/mono-find-requires
mono/Makefile
mono/btls/Makefile
mono/utils/Makefile
mono/metadata/Makefile
mono/dis/Makefile
@@ -4273,12 +4398,28 @@ fi
echo "AOT_BUILD_FLAGS=$AOT_BUILD_FLAGS" >> $srcdir/$mcsdir/build/config.make
fi
if test "x$enable_btls" = "xyes"; then
echo "HAVE_BTLS=1" >> $srcdir/$mcsdir/build/config.make
if test "x$enable_dynamic_btls" = "xyes"; then
echo "HAVE_DYNAMIC_BTLS=1" >> $srcdir/$mcsdir/build/config.make
fi
fi
fi
)
libgdiplus_msg=${libgdiplus_loc:-assumed to be installed}
btls_platform_string=
if test x$enable_btls = xyes; then
if test x$btls_android = xyes; then
btls_platform_string=" (android:$BTLS_PLATFORM)"
else
btls_platform_string=" ($BTLS_PLATFORM)"
fi
fi
echo "
mcs source: $mcsdir
@@ -4304,6 +4445,7 @@ echo "
JNI support: $jdk_headers_found
libgdiplus: $libgdiplus_msg
zlib: $zlib_msg
BTLS: $enable_btls$btls_platform_string
$disabled
"
if test x$with_static_mono = xno -a "x$host_win32" != "xyes"; then
+1
View File
@@ -11,6 +11,7 @@
<dllmap dll="oci" target="libclntsh@libsuffix@" os="!windows"/>
<dllmap dll="db2cli" target="libdb2_36@libsuffix@" os="!windows"/>
<dllmap dll="MonoPosixHelper" target="$mono_libdir/libMonoPosixHelper@libsuffix@" os="!windows" />
<dllmap dll="libmono-btls-shared" target="$mono_libdir/libmono-btls-shared@libsuffix@" os="!windows" />
<dllmap dll="i:msvcrt" target="@LIBC@" os="!windows"/>
<dllmap dll="i:msvcrt.dll" target="@LIBC@" os="!windows"/>
<dllmap dll="sqlite" target="@SQLITE@" os="!windows"/>
+21
View File
@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <direct.h>
#ifdef G_OS_WIN32
#include <io.h>
@@ -68,6 +69,26 @@ int mkstemp (char *tmp_template)
return fd;
}
gchar *
g_mkdtemp (char *tmp_template)
{
gunichar2* utf16_template;
utf16_template = u8to16 (tmp_template);
utf16_template = _wmktemp(utf16_template);
if (utf16_template && *utf16_template) {
if (_wmkdir (utf16_template) == 0){
char *ret = u16to8 (utf16_template);
g_free (utf16_template);
return ret;
}
}
g_free (utf16_template);
return NULL;
}
#ifdef _MSC_VER
#pragma warning(disable:4701)
#endif
+6
View File
@@ -887,6 +887,12 @@ gboolean g_file_test (const gchar *filename, GFileTest test);
#define g_ascii_strtod strtod
#define g_ascii_isalnum isalnum
#ifdef WIN32
gchar *g_mkdtemp (gchar *tmpl);
#else
#define g_mkdtemp mkdtemp
#endif
/*
* Pattern matching
*/
Vendored Submodule
+1
Submodule external/boringssl added at c06ac6b33d.
+1 -1
+1 -1
+42 -7
View File
@@ -24,7 +24,8 @@ dependencies referenced, use the "--deps" command line option.
There are two modes of operation, one uses an existing Mono binary or
a server-hosted list of binaries and is enabled when you use either
the
.B --cross
.B --cross,
.B --sdk
or the
.B --runtime
command line options.
@@ -119,10 +120,19 @@ are using (1.0 or 2.0)
When passed, DIR will be set for the MONO_CFG_DIR environment variable
.TP
.I "--cross target"
Creates a bundle for the specified target platform. The target
must be a directory in ~/.mono/targets/ that contains a "mono"
binary. You can fetch various targets using the --fetch-target
command line option.
Use this to request mkbundle generate a cross-compiled binary. It
Creates a bundle for the specified target platform. The target must
be a directory in ~/.mono/targets/ that contains an SDK installation
as produced by the mono-package-runtime tool. You can get a list of
the precompiled versions of the runtime using --list-targets and you
can fetch a specific target using the --fetch-target command line
option.
.Sp
This flag is mutually exclusive with
.I --sdk
which is used to specify an absolute path to resolve the Mono runtime
from and the --runtime option which is used to manually construct the
cross-platform package.
.TP
.I "--deps"
This option will bundle all of the referenced assemblies for the
@@ -159,10 +169,16 @@ flag to bundle all available encodings.
Or you can use a comma delimited list of the workds CJK, MidWest,
Other, Rare and West to specificy which encoding assemblies to distribute.
.TP
.TP
.I "-L path"
Adds the `path' do the search list for assemblies. The rules are the
same as for the compiler -lib: or -L flags.
.TP
.I "--library [LIB,]PATH"
Embeds the dynamic library file pointed to by `PATH' and optionally
give it the name `LIB' into the bundled executable. This is used to
ship native library dependencies that are unpacked at startup and
loaded from the runtime.
.TP
.I "--lists-targets"
Lists all of the available local cross compilation targets available
as precompiled binaries on the Mono distribution server.
@@ -197,7 +213,26 @@ executed.
Additionally, users of your binary can still configure their own
options by setting the
.I MONO_ENV_OPTIONS
environment variable.
environment variable.
.TP
.I "--sdk SDK_PATH"
Use this flag to specify a path from which mkbundle will resolve the
Mono SDK from. The SDK path should be the prefix path that you used
to configure a Mono installation. And would typically contain files
lik
.I SDK_PATH/bin/mono
,
.I SDK_PATH/lib/mono/4.5
and so on.
.Sp
When this flag is specified,
.I mkbundle
will resolve the runtime, the framework libraries, unmanaged resources
and configuration files from the files located in this directory.
.Sp
This flag is mutually exlusive with
.I --cross
.
.TP
.I "--target-server SERVER"
By default the mkbundle tool will download from a Mono server the
+10 -49
View File
@@ -92,7 +92,7 @@ provided by the Mono runtime and write them to a file named
\f[I]output.mlpd\f[].
When no option is specified, it is equivalent to using:
.PP
\f[B]--profile=log:calls,alloc,output=output.mlpd,maxframes=8,calldepth=100\f[]
\f[B]--profile=log:calls,alloc,output=output.mlpd,maxframes=32,calldepth=100\f[]
.PP
The following options can be used to modify this default behaviour.
Each option is separated from the next by a \f[B],\f[] character,
@@ -139,41 +139,16 @@ garbage collections
to the control port
.RE
.IP \[bu] 2
\f[I]sample[=TYPE[/FREQ]]\f[]: collect statistical samples of the
\f[I]sample[=FREQ]\f[]: collect statistical samples of the
program behaviour.
The default is to collect a 100 times per second (100 Hz) the
instruction pointer.
This is equivalent to the value \[lq]cycles/100\[rq].
This is equivalent to the value \[lq]100\[rq].
A value of zero for \f[I]FREQ\f[] effectively disables sampling.
On some systems, like with recent Linux kernels, it is possible to
cause the sampling to happen for other events provided by the
performance counters of the cpu.
In this case, \f[I]TYPE\f[] can be one of:
.RS 2
.IP \[bu] 2
\f[I]cycles\f[]: processor cycles
.IP \[bu] 2
\f[I]instr\f[]: executed instructions
.IP \[bu] 2
\f[I]cacherefs\f[]: cache references
.IP \[bu] 2
\f[I]cachemiss\f[]: cache misses
.IP \[bu] 2
\f[I]branches\f[]: executed branches
.IP \[bu] 2
\f[I]branchmiss\f[]: mispredicted branches
.RE
.IP \[bu] 2
\f[I]time=TIMER\f[]: use the TIMER timestamp mode.
TIMER can have the following values:
.RS 2
.IP \[bu] 2
\f[I]fast\f[]: a usually faster but possibly more inaccurate timer
.RE
.IP \[bu] 2
\f[I]maxframes=NUM\f[]: when a stack trace needs to be performed,
collect \f[I]NUM\f[] frames at the most.
The default is 8.
The default is 32.
.IP \[bu] 2
\f[I]maxsamples=NUM\f[]: stop allocating reusable sample events
once \f[I]NUM\f[] events have been allocated (a value of zero for
@@ -234,16 +209,15 @@ The following commands are available:
\f[I]heapshot\f[]: perform a heapshot as soon as possible
.RE
.IP \[bu] 2
\f[I]counters\f[]: sample counters values every 1 second. This allow
a really lightweight way to have insight in some of the runtime key
metrics. Counters displayed in non verbose mode are : Methods from AOT,
Methods JITted using mono JIT, Methods JITted using LLVM, Total time
spent JITting (sec), User Time, System Time, Total Time, Working Set,
Private Bytes, Virtual Bytes, Page Faults and CPU Load Average (1min,
5min and 15min).
\f[I]nocounters\f[]: disables sampling of runtime and performance
counters, which is normally done every 1 second.
.IP \[bu] 2
\f[I]coverage\f[]: collect code coverage data. This implies enabling
the \f[I]calls\f[] option.
.IP \[bu] 2
\f[I]onlycoverage\f[]: can only be used with \f[I]coverage\f[]. This
disables most other events so that the profiler mostly only collects
coverage data.
.RE
.SS Analyzing the profile data
.PP
@@ -274,10 +248,6 @@ with the \f[I]--maxframes=NUM\f[] option:
The stack trace info will be available if method enter/leave events
have been recorded or if stack trace collection wasn't explicitly
disabled with the \f[I]maxframes=0\f[] profiler option.
Note that the profiler will collect up to 8 frames by default at
specific events when the \f[I]nocalls\f[] option is used, so in
that case, if more stack frames are required in mprof-report, a
bigger value for maxframes when profiling must be used, too.
.PP
The \f[I]--traces\f[] option also controls the reverse reference
feature in the heapshot report: for each class it reports how many
@@ -487,15 +457,6 @@ option: especially if the managed heap is big, since every object
needs to be inspected.
The \f[I]MODE\f[] parameter of the \f[I]heapshot\f[] option can be
used to reduce the frequency of the heap shots.
.IP "\f[I]Reduce the timestamp overhead\f[]" 4
.Sp
On many operating systems or architectures what actually slows down
profiling is the function provided by the system to get timestamp
information.
The \f[I]time=fast\f[] profiler option can be usually used to speed
up this operation, but, depending on the system, time accounting
may have some level of approximation (though statistically the data
should be still fairly valuable).
.SS Dealing with the size of the data files
.PP
When collecting a lot of information about a profiled program, huge
+2
View File
@@ -42,7 +42,9 @@ executable_CLEAN_FILES += $(build_lib) $(build_lib).so $(build_lib).mdb $(build_
makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
ifndef NO_BUILD
all-local: $(the_lib) $(PROGRAM_config)
endif
install-local: all-local
test-local: all-local
@@ -39,3 +39,5 @@ FRAMEWORK_VERSION = 2.1
NO_INSTALL = yes
MOBILE_STATIC = yes
MOBILE_PROFILE = yes
PROFILE_DISABLE_BTLS=1
+2
View File
@@ -1,9 +1,11 @@
include $(topdir)/build/profiles/monotouch.make
PROFILE_MCS_FLAGS += \
-d:FEATURE_NO_BSD_SOCKETS \
-d:MONOTOUCH_WATCH
NO_THREAD_ABORT=1
NO_THREAD_SUSPEND_RESUME=1
NO_MULTIPLE_APPDOMAINS=1
NO_PROCESS_START=1
NO_MONO_SECURITY=1
@@ -1,6 +1,7 @@
include $(topdir)/build/profiles/monotouch_runtime.make
PROFILE_MCS_FLAGS += \
-d:FEATURE_NO_BSD_SOCKETS \
-d:MONOTOUCH_WATCH
NO_THREAD_ABORT=1
@@ -8,3 +9,4 @@ NO_THREAD_SUSPEND_RESUME=1
# The binding generator (bwatch) still needs to execute processes,
# so we need a System.dll that can do that.
#NO_PROCESS_START=1
NO_MONO_SECURITY=1
+2
View File
@@ -35,3 +35,5 @@ NO_TEST = yes
NO_INSTALL = yes
MOBILE_DYNAMIC = yes
MOBILE_PROFILE = yes
PROFILE_DISABLE_BTLS=1
+2
View File
@@ -15,3 +15,5 @@ NO_SYSTEM_DRAWING_DEPENDENCY=1
NO_SYSTEM_SERVICEMODEL_ACTIVATION_DEPENDENCY=1
NO_SYSTEM_DESIGN_DEPENDENCY=1
NO_SYSTEM_DIRECTORY_SERVICES_DEPENDENCY=1
PROFILE_DISABLE_BTLS=1
@@ -1,3 +1,2 @@
TypeForwarders.cs
AssemblyInfo.cs
EventCounter.cs
@@ -44,3 +44,7 @@
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventTask))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventWrittenEventArgs))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.NonEventAttribute))]
#if NETSTANDARD
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventCounter))]
#endif
@@ -1,5 +1,2 @@
TypeForwarders.cs
AssemblyInfo.cs
SocketReceiveFromResult.cs
SocketReceiveMessageFromResult.cs
SocketTaskExtensions.cs
@@ -46,4 +46,8 @@
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.UdpClient))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.UdpReceiveResult))]
#if NETSTANDARD
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketReceiveFromResult))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketReceiveMessageFromResult))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketTaskExtensions))]
#endif
@@ -0,0 +1,136 @@
//
// DynamicMethod.cs
//
// Authors:
// Marek Safar ([email protected])
//
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if FULL_AOT_RUNTIME
namespace System.Reflection.Emit
{
public abstract class DynamicMethod : MethodInfo, ICustomAttributeProvider
{
public DynamicMethod (string name, Type returnType, Type[] parameterTypes)
{
throw new PlatformNotSupportedException ();
}
public DynamicMethod (string name, Type returnType, Type[] parameterTypes, bool restrictedSkipVisibility)
{
throw new PlatformNotSupportedException ();
}
public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Module m)
{
throw new PlatformNotSupportedException ();
}
public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Type owner)
{
throw new PlatformNotSupportedException ();
}
public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility)
{
throw new PlatformNotSupportedException ();
}
public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility)
{
throw new PlatformNotSupportedException ();
}
public DynamicMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility)
{
throw new PlatformNotSupportedException ();
}
public DynamicMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility)
{
throw new PlatformNotSupportedException ();
}
public override MethodAttributes Attributes {
get {
throw new PlatformNotSupportedException ();
}
}
public override CallingConventions CallingConvention {
get {
throw new PlatformNotSupportedException ();
}
}
public override Type DeclaringType {
get {
throw new PlatformNotSupportedException ();
}
}
public bool InitLocals { get; set; }
public override MethodImplAttributes MethodImplementationFlags {
get {
throw new PlatformNotSupportedException ();
}
}
public override string Name {
get {
throw new PlatformNotSupportedException ();
}
}
public override ParameterInfo ReturnParameter {
get {
throw new PlatformNotSupportedException ();
}
}
public override Type ReturnType {
get {
throw new PlatformNotSupportedException ();
}
}
public ILGenerator GetILGenerator ()
{
throw new PlatformNotSupportedException ();
}
public ILGenerator GetILGenerator (int streamSize)
{
throw new PlatformNotSupportedException ();
}
public override ParameterInfo[] GetParameters ()
{
throw new PlatformNotSupportedException ();
}
}
}
#endif
@@ -1,3 +1,3 @@
TypeForwarders.cs
AssemblyInfo.cs
DynamicMethod.cs
@@ -20,5 +20,6 @@
// THE SOFTWARE.
//
#if !FULL_AOT_RUNTIME
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Reflection.Emit.DynamicMethod))]
#endif
+3 -5
View File
@@ -24,7 +24,7 @@ System.Security.Cryptography.Encryption.Aes System.Security.Cryptography.Encrypt
System.Security.Cryptography.Hashing.Algorithms System.Security.Cryptography.RSA System.Security.Cryptography.RandomNumberGenerator \
System.Security.Principal.Windows System.Threading.Thread System.Threading.ThreadPool \
System.Xml.XPath System.Xml.XmlDocument System.Xml.Xsl.Primitives Microsoft.Win32.Registry.AccessControl System.Diagnostics.StackTrace System.Globalization.Extensions \
System.IO.FileSystem.AccessControl System.Reflection.TypeExtensions \
System.IO.FileSystem.AccessControl System.Reflection.TypeExtensions System.Reflection.Emit.Lightweight System.Reflection.Emit.ILGeneration System.Reflection.Emit \
System.Security.SecureString System.Threading.AccessControl System.Threading.Overlapped System.Xml.XPath.XDocument \
System.Security.Cryptography.Primitives System.Text.Encoding.CodePages System.IO.FileSystem.Watcher \
System.Security.Cryptography.ProtectedData System.ServiceProcess.ServiceController System.IO.Pipes
@@ -34,8 +34,6 @@ common_DEPS_SUBDIRS = System.Security.Cryptography.X509Certificates System.Servi
drawing_DEPS_SUBDIRS = System.Drawing.Primitives
reflection_PARALLEL_SUBDIRS = System.Reflection.Emit.ILGeneration System.Reflection.Emit.Lightweight System.Reflection.Emit
monotouch_SUBDIRS = $(common_DEPS_SUBDIRS) $(mobile_only_DEPS_SUBDIRS)
monotouch_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(mobile_only_SUBDIRS)
@@ -43,10 +41,10 @@ mobile_static_SUBDIRS = $(monotouch_SUBDIRS)
mobile_static_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
net_4_x_SUBDIRS = $(common_DEPS_SUBDIRS) $(drawing_DEPS_SUBDIRS)
net_4_x_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
net_4_x_PARALLEL_SUBDIRS = $(common_SUBDIRS)
monodroid_SUBDIRS = $(monotouch_SUBDIRS)
monodroid_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
monodroid_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
xammac_SUBDIRS = $(monotouch_SUBDIRS)
xammac_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
+6 -14
View File
@@ -51,9 +51,6 @@ mobile_common_dirs := \
System.Xml.Serialization \
Mono.CSharp \
Microsoft.CSharp \
Mono.Security.Providers.DotNet \
Mono.Security.Providers.NewSystemSource \
Mono.Security.Providers.NewTls \
System.Runtime.InteropServices.RuntimeInformation \
System.Reflection.DispatchProxy \
System.Xml.XPath.XmlDocument \
@@ -77,12 +74,13 @@ xammac_dirs := \
$(mobile_dynamic_dirs)
monodroid_dirs := \
$(mobile_dynamic_dirs)
$(mobile_dynamic_dirs) \
Mono.Btls.Interface
monotouch_dirs := \
$(mobile_static_dirs)
monotouch_watch_dirs := $(monotouch_dirs)
monotouch_watch_dirs := $(filter-out Mono.Security Mono.Data.Tds,$(monotouch_dirs))
monotouch_tv_dirs := $(monotouch_dirs)
monotouch_runtime_dirs := \
@@ -93,7 +91,7 @@ monotouch_runtime_dirs := \
System.XML \
Mono.CSharp
monotouch_watch_runtime_dirs := $(monotouch_runtime_dirs)
monotouch_watch_runtime_dirs := $(filter-out Mono.Security Mono.Data.Tds,$(monotouch_runtime_dirs))
monotouch_tv_runtime_dirs := $(monotouch_runtime_dirs)
xammac_4_5_dirs := \
@@ -108,6 +106,7 @@ xammac_4_5_dirs := \
System.ServiceModel.Internals \
SMDiagnostics \
System.Numerics \
System.Numerics.Vectors \
Mono.Data.Tds \
System.Transactions \
System.EnterpriseServices \
@@ -139,10 +138,6 @@ xammac_4_5_dirs := \
System.Data.Linq \
System.Net.Http \
System.Net.Http.WebRequest \
Mono.Security.Providers.DotNet \
Mono.Security.Providers.OldTls \
Mono.Security.Providers.NewSystemSource \
Mono.Security.Providers.NewTls \
System.Runtime.InteropServices.RuntimeInformation \
System.Reflection.Context \
System.Net.Http.WinHttpHandler \
@@ -231,8 +226,6 @@ net_4_x_dirs := \
System.Web.Http \
System.Web.Http.SelfHost \
System.Web.Http.WebHost \
Mono.Security.Providers.NewSystemSource \
Mono.Security.Providers.NewTls \
System.Runtime.InteropServices.RuntimeInformation
# These are the subdirs which depends on libs in net_4_x_dirs
@@ -240,6 +233,7 @@ net_4_x_dirs := \
net_4_x_parallel_dirs := \
PEAPI \
I18N \
Mono.Btls.Interface \
Mono.Http \
Mono.Cairo \
Mono.Cecil \
@@ -276,8 +270,6 @@ net_4_x_parallel_dirs := \
System.ComponentModel.Composition.4.5 \
System.Windows \
System.Xml.Serialization \
Mono.Security.Providers.DotNet \
Mono.Security.Providers.OldTls \
System.DirectoryServices.Protocols \
RabbitMQ.Client \
Microsoft.VisualC \
@@ -226,6 +226,14 @@ namespace Microsoft.Build.BuildEngine {
public void SetMetadata (string metadataName,
string metadataValue,
bool treatMetadataValueAsLiteral)
{
SetMetadata (metadataName, metadataValue, treatMetadataValueAsLiteral, false);
}
void SetMetadata (string metadataName,
string metadataValue,
bool treatMetadataValueAsLiteral,
bool fromDynamicItem)
{
if (metadataName == null)
throw new ArgumentNullException ("metadataName");
@@ -251,9 +259,11 @@ namespace Microsoft.Build.BuildEngine {
} else if (HasParentItem) {
if (parent_item.child_items.Count > 1)
SplitParentItem ();
parent_item.SetMetadata (metadataName, metadataValue, treatMetadataValueAsLiteral);
parent_item.SetMetadata (metadataName, metadataValue, treatMetadataValueAsLiteral, fromDynamicItem);
}
if (FromXml || HasParentItem) {
// We don't want to reevalute the project for dynamic items
if (!fromDynamicItem && !IsDynamic && (FromXml || HasParentItem)) {
parent_item_group.ParentProject.MarkProjectAsDirty ();
parent_item_group.ParentProject.NeedToReevaluate ();
}
@@ -374,7 +384,7 @@ namespace Microsoft.Build.BuildEngine {
continue;
foreach (string name in evaluatedMetadata.Keys) {
item.SetMetadata (name, (string)evaluatedMetadata [name]);
item.SetMetadata (name, (string)evaluatedMetadata [name], false, IsDynamic);
}
AddAndRemoveMetadata (project, item);
@@ -697,6 +697,33 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Project>", "D");
}
[Test]
public void ItemGroupInsideTarget_UpdateMetadata ()
{
ItemGroupInsideTarget (
@"<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<ProjectReference Include='xyz'/>
</ItemGroup>
<Target Name='Main' DependsOnTargets='CreateBar'>
<Message Text='Before: $(Bar)'/>
<ItemGroup>
<ProjectReference>
<AdditionalProperties>A=b</AdditionalProperties>
</ProjectReference>
</ItemGroup>
<Message Text='After: $(Bar)'/>
</Target>
<Target Name='CreateBar'>
<PropertyGroup>
<Bar>Bar01</Bar>
</PropertyGroup>
</Target>
</Project>", 2, "Before: Bar01", "After: Bar01");
}
[Test]
public void ItemGroupInsideTarget_Batching ()
{
@@ -153,7 +153,10 @@ namespace Microsoft.Build.Tasks {
{
if (!string.IsNullOrEmpty (ToolPath))
return Path.Combine (ToolPath, ToolExe);
return ToolLocationHelper.GetPathToDotNetFrameworkFile (ToolExe, TargetDotNetFrameworkVersion.VersionLatest);
var possibleToolPath = ToolLocationHelper.GetPathToDotNetFrameworkFile (ToolExe, TargetDotNetFrameworkVersion.VersionLatest);
if (!string.IsNullOrEmpty(possibleToolPath))
return possibleToolPath;
return ToolLocationHelper.GetPathToDotNetFrameworkBinFile(ToolExe);
}
[MonoTODO]
@@ -93,7 +93,8 @@ namespace Microsoft.CSharp.RuntimeBinder
module.SetDeclaringAssembly (temp);
var importer = new Compiler.ReflectionImporter (module, cc.BuiltinTypes) {
IgnorePrivateMembers = false
IgnorePrivateMembers = false,
IgnoreCompilerGeneratedField = false
};
// Import all currently loaded assemblies
@@ -1,11 +1,18 @@
thisdir = class/Mono.Security.Providers.OldTls
thisdir = class/Mono.Btls.Interface
SUBDIRS =
include ../../build/rules.make
LIBRARY = Mono.Security.Providers.OldTls.dll
LIBRARY = Mono.Btls.Interface.dll
LIB_REFS = System Mono.Security
LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:SECURITY_DEP
ifndef HAVE_BTLS
NO_INSTALL = yes
NO_SIGN_ASSEMBLY = yes
NO_TEST = yes
NO_BUILD = yes
endif
include ../../build/library.make
$(the_lib): ../Mono.Security/Makefile
@@ -0,0 +1,22 @@
./Properties/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
../../build/common/MonoTODOAttribute.cs
Mono.Btls.Interface/BtlsObject.cs
Mono.Btls.Interface/BtlsProvider.cs
Mono.Btls.Interface/BtlsX509.cs
Mono.Btls.Interface/BtlsX509Chain.cs
Mono.Btls.Interface/BtlsX509Error.cs
Mono.Btls.Interface/BtlsX509Format.cs
Mono.Btls.Interface/BtlsX509Lookup.cs
Mono.Btls.Interface/BtlsX509Name.cs
Mono.Btls.Interface/BtlsX509Purpose.cs
Mono.Btls.Interface/BtlsX509Store.cs
Mono.Btls.Interface/BtlsX509StoreCtx.cs
Mono.Btls.Interface/BtlsX509StoreManager.cs
Mono.Btls.Interface/BtlsX509StoreType.cs
Mono.Btls.Interface/BtlsX509TrustKind.cs
Mono.Btls.Interface/BtlsX509VerifyFlags.cs
Mono.Btls.Interface/BtlsX509VerifyParam.cs
Mono.Btls.Interface/VersionInfo.cs
@@ -1,10 +1,10 @@
//
// ITlsContext.cs
// BtlsObject.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015-2016 Xamarin, Inc.
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -23,48 +23,51 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern alias NewSystemSource;
using System;
using System.Security.Cryptography;
using Mono.Security.Interface;
using MX = Mono.Security.X509;
namespace Mono.Security.Providers.NewTls
namespace Mono.Btls.Interface
{
interface ITlsContext : IDisposable
public abstract class BtlsObject : IDisposable
{
bool IsValid {
get;
MonoBtlsObject instance;
internal MonoBtlsObject Instance {
get {
if (!IsValid)
throw new ObjectDisposedException (GetType ().Name);
return instance;
}
}
TlsException LastError {
get;
internal BtlsObject (MonoBtlsObject instance)
{
this.instance = instance;
}
bool ReceivedCloseNotify {
get;
public bool IsValid {
get { return instance != null && instance.IsValid; }
}
MonoTlsConnectionInfo ConnectionInfo {
get;
protected void Dispose (bool disposing)
{
if (disposing) {
if (instance != null) {
instance.Dispose ();
instance = null;
}
}
}
MX.X509Certificate GetRemoteCertificate (out MX.X509CertificateCollection remoteCertificateStore);
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
bool VerifyRemoteCertificate ();
int GenerateNextToken (TlsBuffer incoming, TlsMultiBuffer outgoing);
int DecryptMessage (ref TlsBuffer incoming);
int EncryptMessage (ref TlsBuffer incoming);
byte[] CreateAlert (Alert alert);
byte[] CreateHelloRequest ();
~BtlsObject ()
{
Dispose (false);
}
}
}
@@ -0,0 +1,107 @@
//
// BtlsProvider.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using Mono.Security.Interface;
using System.Security.Cryptography.X509Certificates;
using MNS = Mono.Net.Security;
namespace Mono.Btls.Interface
{
public static class BtlsProvider
{
public static bool IsSupported ()
{
return MNS.MonoTlsProviderFactory.IsBtlsSupported ();
}
public static MonoTlsProvider GetProvider ()
{
return new MonoBtlsProvider ();
}
public static BtlsX509 CreateNative (byte[] data, BtlsX509Format format)
{
var x509 = MonoBtlsX509.LoadFromData (data, (MonoBtlsX509Format)format);
return new BtlsX509 (x509);
}
public static X509Certificate CreateCertificate (byte[] data, BtlsX509Format format, bool disallowFallback = false)
{
return MonoBtlsProvider.CreateCertificate (data, (MonoBtlsX509Format)format, disallowFallback);
}
public static X509Certificate2 CreateCertificate2 (byte[] data, BtlsX509Format format, bool disallowFallback = false)
{
return MonoBtlsProvider.CreateCertificate2 (data, (MonoBtlsX509Format)format, disallowFallback);
}
public static X509Certificate2 CreateCertificate2 (byte[] data, string password, bool disallowFallback = false)
{
return MonoBtlsProvider.CreateCertificate2 (data, password, disallowFallback);
}
public static BtlsX509Chain CreateNativeChain ()
{
return new BtlsX509Chain (new MonoBtlsX509Chain ());
}
public static BtlsX509Store CreateNativeStore ()
{
return new BtlsX509Store (new MonoBtlsX509Store ());
}
public static BtlsX509StoreCtx CreateNativeStoreCtx ()
{
return new BtlsX509StoreCtx (new MonoBtlsX509StoreCtx ());
}
public static X509Chain CreateChain ()
{
return MonoBtlsProvider.CreateChain ();
}
public static string GetSystemStoreLocation ()
{
return MonoBtlsProvider.GetSystemStoreLocation ();
}
public static BtlsX509VerifyParam GetVerifyParam_SslClient ()
{
return new BtlsX509VerifyParam (MonoBtlsX509VerifyParam.GetSslClient ());
}
public static BtlsX509VerifyParam GetVerifyParam_SslServer ()
{
return new BtlsX509VerifyParam (MonoBtlsX509VerifyParam.GetSslServer ());
}
public static X509Chain GetManagedChain (BtlsX509Chain chain)
{
return MonoBtlsProvider.GetManagedChain (chain.Instance);
}
}
}
@@ -0,0 +1,132 @@
//
// BtlsX509.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Security.Cryptography;
namespace Mono.Btls.Interface
{
public class BtlsX509 : BtlsObject
{
new internal MonoBtlsX509 Instance {
get { return (MonoBtlsX509)base.Instance; }
}
internal BtlsX509 (MonoBtlsX509 x509)
: base (x509)
{
}
public BtlsX509Name GetSubjectName ()
{
return new BtlsX509Name (Instance.GetSubjectName ());
}
public BtlsX509Name GetIssuerName ()
{
return new BtlsX509Name (Instance.GetIssuerName ());
}
public string GetSubjectNameString ()
{
return Instance.GetSubjectNameString ();
}
public string GetIssuerNameString ()
{
return Instance.GetIssuerNameString ();
}
public byte[] GetRawData (BtlsX509Format format)
{
return Instance.GetRawData ((MonoBtlsX509Format)format);
}
public byte[] GetCertHash ()
{
return Instance.GetCertHash ();
}
public DateTime GetNotBefore ()
{
return Instance.GetNotBefore ();
}
public DateTime GetNotAfter ()
{
return Instance.GetNotAfter ();
}
public byte[] GetPublicKeyData ()
{
return Instance.GetPublicKeyData ();
}
public byte[] GetSerialNumber (bool mono_style)
{
return Instance.GetSerialNumber (mono_style);
}
public int GetVersion ()
{
return Instance.GetVersion ();
}
public Oid GetSignatureAlgorithm ()
{
return Instance.GetSignatureAlgorithm ();
}
public AsnEncodedData GetPublicKeyAsn1 ()
{
return Instance.GetPublicKeyAsn1 ();
}
public AsnEncodedData GetPublicKeyParameters ()
{
return Instance.GetPublicKeyParameters ();
}
public long GetSubjectNameHash ()
{
using (var name = GetSubjectName ())
return name.GetHash ();
}
public void Print (Stream stream)
{
using (var bio = MonoBtlsBio.CreateMonoStream (stream))
Instance.Print (bio);
}
public void ExportAsPEM (Stream stream, bool includeHumanReadableForm)
{
using (var bio = MonoBtlsBio.CreateMonoStream (stream))
Instance.ExportAsPEM (bio, includeHumanReadableForm);
}
}
}
@@ -0,0 +1,58 @@
//
// BtlsX509Chain.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
public class BtlsX509Chain : BtlsObject
{
new internal MonoBtlsX509Chain Instance {
get { return (MonoBtlsX509Chain)base.Instance; }
}
internal BtlsX509Chain (MonoBtlsX509Chain chain)
: base (chain)
{
}
public int Count {
get { return Instance.Count; }
}
public BtlsX509 this[int index] {
get {
var x509 = Instance.GetCertificate (index);
return new BtlsX509 (x509.Copy ());
}
}
public void Add (BtlsX509 x509)
{
Instance.AddCertificate (x509.Instance);
}
}
}
@@ -0,0 +1,110 @@
//
// BtlsX509Error.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
// Keep in sync with NativeBoringX509Error
public enum BtlsX509Error
{
OK = 0,
/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */
UNABLE_TO_GET_ISSUER_CERT = 2,
UNABLE_TO_GET_CRL = 3,
UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4,
UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5,
UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6,
CERT_SIGNATURE_FAILURE = 7,
CRL_SIGNATURE_FAILURE = 8,
CERT_NOT_YET_VALID = 9,
CERT_HAS_EXPIRED = 10,
CRL_NOT_YET_VALID = 11,
CRL_HAS_EXPIRED = 12,
ERROR_IN_CERT_NOT_BEFORE_FIELD = 13,
ERROR_IN_CERT_NOT_AFTER_FIELD = 14,
ERROR_IN_CRL_LAST_UPDATE_FIELD = 15,
ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16,
OUT_OF_MEM = 17,
DEPTH_ZERO_SELF_SIGNED_CERT = 18,
SELF_SIGNED_CERT_IN_CHAIN = 19,
UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20,
UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21,
CERT_CHAIN_TOO_LONG = 22,
CERT_REVOKED = 23,
INVALID_CA = 24,
PATH_LENGTH_EXCEEDED = 25,
INVALID_PURPOSE = 26,
CERT_UNTRUSTED = 27,
CERT_REJECTED = 28,
/* These are 'informational' when looking for issuer cert */
SUBJECT_ISSUER_MISMATCH = 29,
AKID_SKID_MISMATCH = 30,
AKID_ISSUER_SERIAL_MISMATCH = 31,
KEYUSAGE_NO_CERTSIGN = 32,
UNABLE_TO_GET_CRL_ISSUER = 33,
UNHANDLED_CRITICAL_EXTENSION = 34,
KEYUSAGE_NO_CRL_SIGN = 35,
UNHANDLED_CRITICAL_CRL_EXTENSION = 36,
INVALID_NON_CA = 37,
PROXY_PATH_LENGTH_EXCEEDED = 38,
KEYUSAGE_NO_DIGITAL_SIGNATURE = 39,
PROXY_CERTIFICATES_NOT_ALLOWED = 40,
INVALID_EXTENSION = 41,
INVALID_POLICY_EXTENSION = 42,
NO_EXPLICIT_POLICY = 43,
DIFFERENT_CRL_SCOPE = 44,
UNSUPPORTED_EXTENSION_FEATURE = 45,
UNNESTED_RESOURCE = 46,
PERMITTED_VIOLATION = 47,
EXCLUDED_VIOLATION = 48,
SUBTREE_MINMAX = 49,
UNSUPPORTED_CONSTRAINT_TYPE = 51,
UNSUPPORTED_CONSTRAINT_SYNTAX = 52,
UNSUPPORTED_NAME_SYNTAX = 53,
CRL_PATH_VALIDATION_ERROR = 54,
/* Suite B mode algorithm violation */
SUITE_B_INVALID_VERSION = 56,
SUITE_B_INVALID_ALGORITHM = 57,
SUITE_B_INVALID_CURVE = 58,
SUITE_B_INVALID_SIGNATURE_ALGORITHM = 59,
SUITE_B_LOS_NOT_ALLOWED = 60,
SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 = 61,
/* Host, email and IP check errors */
HOSTNAME_MISMATCH = 62,
EMAIL_MISMATCH = 63,
IP_ADDRESS_MISMATCH = 64,
/* The application is not happy */
APPLICATION_VERIFICATION = 50
}
}
@@ -0,0 +1,37 @@
//
// BtlsX509Format.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
// Keep in sync with NativeBoringX509Format
public enum BtlsX509Format
{
DER = 1,
PEM = 2
}
}
@@ -1,10 +1,10 @@
//
// IMonoTlsContext.cs
// BtlsX509Lookup.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,48 +24,49 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Interface
namespace Mono.Btls.Interface
{
interface IMonoTlsContext : IDisposable
public class BtlsX509Lookup : BtlsObject
{
bool IsServer {
get;
new internal MonoBtlsX509Lookup Instance {
get { return (MonoBtlsX509Lookup)base.Instance; }
}
bool IsValid {
get;
internal BtlsX509Lookup (MonoBtlsX509Lookup lookup)
: base (lookup)
{
}
void Initialize (IMonoTlsEventSink eventSink);
bool HasCredentials {
get;
public void Initialize ()
{
Instance.Initialize ();
}
void SetCertificate (X509Certificate certificate, AsymmetricAlgorithm privateKey);
int GenerateNextToken (IBufferOffsetSize incoming, out IBufferOffsetSize outgoing);
int EncryptMessage (ref IBufferOffsetSize incoming);
int DecryptMessage (ref IBufferOffsetSize incoming);
bool ReceivedCloseNotify {
get;
public void Shutdown ()
{
Instance.Shutdown ();
}
byte[] CreateCloseNotify ();
public BtlsX509 LookupBySubject (BtlsX509Name name)
{
var x509 = Instance.LookupBySubject (name.Instance);
if (x509 == null)
return null;
byte[] CreateHelloRequest ();
return new BtlsX509 (x509);
}
X509Certificate GetRemoteCertificate (out X509CertificateCollection remoteCertificateStore);
public void LoadFile (string file, BtlsX509Format type)
{
Instance.LoadFile (file, (MonoBtlsX509FileType)type);
}
bool VerifyRemoteCertificate ();
MonoTlsConnectionInfo GetConnectionInfo ();
public void AddDirectory (string dir, BtlsX509Format type)
{
Instance.AddDirectory (dir, (MonoBtlsX509FileType)type);
}
}
}
@@ -0,0 +1,62 @@
//
// BtlsX509Name.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
public class BtlsX509Name : BtlsObject
{
new internal MonoBtlsX509Name Instance {
get { return (MonoBtlsX509Name)base.Instance; }
}
internal BtlsX509Name (MonoBtlsX509Name name)
: base (name)
{
}
public string GetString ()
{
return Instance.GetString ();
}
public byte[] GetRawData (bool use_canon_enc)
{
return Instance.GetRawData (use_canon_enc);
}
public long GetHash ()
{
return Instance.GetHash ();
}
public long GetHashOld ()
{
return Instance.GetHashOld ();
}
}
}
@@ -0,0 +1,43 @@
//
// BtlsX509Purpose.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
// Keep in sync with NativeBoringX509Purpose
public enum BtlsX509Purpose
{
SSL_CLIENT = 1,
SSL_SERVER = 2,
NS_SSL_SERVER = 3,
SMIME_SIGN = 4,
SMIME_ENCRYPT = 5,
CRL_SIGN = 6,
ANY = 7,
OCSP_HELPER = 8,
TIMESTAMP_SIGN = 9,
}
}
@@ -0,0 +1,91 @@
//
// BtlsX509Store.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Security.Cryptography.X509Certificates;
namespace Mono.Btls.Interface
{
public class BtlsX509Store : BtlsObject
{
new internal MonoBtlsX509Store Instance {
get { return (MonoBtlsX509Store)base.Instance; }
}
internal BtlsX509Store (MonoBtlsX509Store store)
: base (store)
{
}
public void LoadLocations (string file, string path)
{
Instance.LoadLocations (file, path);
}
public void AddTrustedRoots ()
{
Instance.AddTrustedRoots ();
}
public void AddCertificate (BtlsX509 x509)
{
Instance.AddCertificate (x509.Instance);
}
public int GetCount ()
{
return Instance.GetCount ();
}
public void AddLookup (X509CertificateCollection certificates, BtlsX509TrustKind trust)
{
Instance.AddCollection (certificates, (MonoBtlsX509TrustKind)trust);
}
static MonoBtlsX509FileType GetFileType (BtlsX509Format format)
{
switch (format) {
case BtlsX509Format.DER:
return MonoBtlsX509FileType.ASN1;
case BtlsX509Format.PEM:
return MonoBtlsX509FileType.PEM;
default:
throw new NotSupportedException ();
}
}
public void AddDirectoryLookup (string dir, BtlsX509Format format)
{
Instance.AddDirectoryLookup (dir, GetFileType (format));
}
public void AddFileLookup (string file, BtlsX509Format format)
{
Instance.AddFileLookup (file, GetFileType (format));
}
}
}
@@ -0,0 +1,71 @@
//
// BtlsX509StoreCtx.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
public class BtlsX509StoreCtx : BtlsObject
{
new internal MonoBtlsX509StoreCtx Instance {
get { return (MonoBtlsX509StoreCtx)base.Instance; }
}
internal BtlsX509StoreCtx (MonoBtlsX509StoreCtx ctx)
: base (ctx)
{
}
public void Initialize (BtlsX509Store store, BtlsX509Chain chain)
{
Instance.Initialize (store.Instance, chain.Instance);
}
public void SetVerifyParam (BtlsX509VerifyParam param)
{
Instance.SetVerifyParam (param.Instance);
}
public int Verify ()
{
return Instance.Verify ();
}
public BtlsX509Error GetError ()
{
return (BtlsX509Error)Instance.GetError ();
}
public Exception GetException ()
{
return Instance.GetException ();
}
public BtlsX509Chain GetChain ()
{
return new BtlsX509Chain (Instance.GetChain ());
}
}
}
@@ -0,0 +1,44 @@
//
// BtlsX509StoreManager.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Security.Cryptography;
namespace Mono.Btls.Interface
{
public static class BtlsX509StoreManager
{
public static bool HasStore (BtlsX509StoreType type)
{
return MonoBtlsX509StoreManager.HasStore ((MonoBtlsX509StoreType)type);
}
public static string GetStorePath (BtlsX509StoreType type)
{
return MonoBtlsX509StoreManager.GetStorePath ((MonoBtlsX509StoreType)type);
}
}
}
@@ -1,10 +1,10 @@
//
// ITlsContext.cs
// BtlsX509StoreType.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015-2016 Xamarin, Inc.
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -23,25 +23,21 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Security.Cryptography;
using Mono.Security.Interface;
using MX = Mono.Security.X509;
namespace Mono.Security.Providers.NewTls
namespace Mono.Btls.Interface
{
interface ITlsConfiguration
// Keep in sync with MonoBtlsX509StoreType
public enum BtlsX509StoreType
{
bool HasCredentials {
get;
}
void SetCertificate (MX.X509Certificate certificate, AsymmetricAlgorithm privateKey);
bool? AskForClientCertificate {
get; set;
}
Custom,
MachineTrustedRoots,
MachineIntermediateCA,
MachineUntrusted,
UserTrustedRoots,
UserIntermediateCA,
UserUntrusted
}
}
@@ -0,0 +1,42 @@
//
// BtlsX509TrustKind.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
// Keep in sync with MonoBtlsX509TrustKind
[Flags]
public enum BtlsX509TrustKind
{
DEFAULT = 0,
TRUST_CLIENT = 1,
TRUST_SERVER = 2,
TRUST_ALL = 4,
REJECT_CLIENT = 32,
REJECT_SERVER = 64,
REJECT_ALL = 128
}
}
@@ -0,0 +1,38 @@
//
// BtlsX509VerifyFlags.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
// Keep in sync with NativeBoringX509VerifyFlags
public enum BtlsX509VerifyFlags
{
DEFAULT = 0,
CRL_CHECK = 1,
CRL_CHECK_ALL = 2,
X509_STRIC = 4
}
}
@@ -0,0 +1,91 @@
//
// BtlsX509VerifyParam.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
public class BtlsX509VerifyParam : BtlsObject
{
new internal MonoBtlsX509VerifyParam Instance {
get { return (MonoBtlsX509VerifyParam)base.Instance; }
}
internal BtlsX509VerifyParam (MonoBtlsX509VerifyParam param)
: base (param)
{
}
public BtlsX509VerifyParam Copy ()
{
return new BtlsX509VerifyParam (Instance.Copy ());
}
public void SetName (string name)
{
Instance.SetName (name);
}
public void SetHost (string name)
{
Instance.SetHost (name);
}
public void AddHost (string name)
{
Instance.AddHost (name);
}
public BtlsX509VerifyFlags GetFlags ()
{
return (BtlsX509VerifyFlags)Instance.GetFlags ();
}
public void SetFlags (BtlsX509VerifyFlags flags)
{
Instance.SetFlags ((ulong)flags);
}
public void SetPurpose (BtlsX509Purpose purpose)
{
Instance.SetPurpose ((MonoBtlsX509Purpose)purpose);
}
public int GetDepth ()
{
return Instance.GetDepth ();
}
public void SetDepth (int depth)
{
Instance.SetDepth (depth);
}
public void SetTime (DateTime time)
{
Instance.SetTime (time);
}
}
}
@@ -0,0 +1,34 @@
//
// VersionInfo.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.Btls.Interface
{
public static class VersionInfo
{
public const string Version = "1.0.0";
}
}
@@ -1,10 +1,11 @@
//
//
// AssemblyInfo.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -36,10 +37,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: AssemblyCompany ("MONO development team")]
[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
[assembly: AssemblyDescription ("Mono.Security.Providers.DotNet.dll")]
[assembly: AssemblyCopyright ("(c) 2016 Xamarin")]
[assembly: AssemblyDescription ("Mono.Btls.Interface")]
[assembly: AssemblyProduct ("MONO CLI")]
[assembly: AssemblyTitle ("Mono.Security.Providers.DotNet.dll")]
[assembly: AssemblyTitle ("Mono.Btls.Interface")]
[assembly: CLSCompliant (true)]
[assembly: ComVisible (false)]
[assembly: NeutralResourcesLanguage ("en-US")]
+9
View File
@@ -0,0 +1,9 @@
Mono.Btls.Interface
===================
The purpose of this assembly is to allow test suites such as xamarin/web-tests
(https://github.com/xamarin/web-tests/tree/stable) to test parts of BTLS without
making System.dll internals visible.
It should not be considered a stable and maintained API for third parties.
@@ -1,13 +1,4 @@
#include Mono.CSharp.dll.sources
../corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
../corlib/System.Reflection.Emit/FlowControl.cs
../corlib/System.Reflection.Emit/OpCode.cs
../corlib/System.Reflection.Emit/OpCodeNames.cs
../corlib/System.Reflection.Emit/OpCodes.cs
../corlib/System.Reflection.Emit/OpCodeType.cs
../corlib/System.Reflection.Emit/OperandType.cs
../corlib/System.Reflection.Emit/PEFileKinds.cs
../corlib/System.Reflection.Emit/Label.cs
../corlib/System.Reflection.Emit/MethodToken.cs
../corlib/System.Reflection.Emit/StackBehaviour.cs
monotouch.cs
-304
View File
@@ -28,66 +28,6 @@
namespace System.Reflection.Emit
{
public class ILGenerator
{
public void BeginCatchBlock (Type exceptionType)
{
throw new NotSupportedException ();
}
public Label BeginExceptionBlock ()
{
throw new NotSupportedException ();
}
public void BeginExceptFilterBlock ()
{
throw new NotSupportedException ();
}
public void BeginFinallyBlock ()
{
throw new NotSupportedException ();
}
public LocalBuilder DeclareLocal (params object[] args)
{
throw new NotSupportedException ();
}
public Label DefineLabel ()
{
throw new NotSupportedException ();
}
public void Emit (OpCode opcode)
{
throw new NotSupportedException ();
}
public void Emit (OpCode opcode, object args)
{
throw new NotSupportedException ();
}
public void EmitCall (OpCode opcode, params object[] args)
{
throw new NotSupportedException ();
}
public void EndExceptionBlock ()
{
throw new NotSupportedException ();
}
public void MarkLabel (Label loc)
{
throw new NotSupportedException ();
}
public int ILOffset { get; set; }
}
public class TypeBuilder : Type
{
#region implemented abstract members of MemberInfo
@@ -528,230 +468,6 @@ namespace System.Reflection.Emit
}
}
public class LocalBuilder : LocalVariableInfo
{
}
public class GenericTypeParameterBuilder : Type
{
#region implemented abstract members of MemberInfo
public override bool IsDefined (Type attributeType, bool inherit)
{
throw new NotSupportedException ();
}
public override object[] GetCustomAttributes (bool inherit)
{
throw new NotSupportedException ();
}
public override object[] GetCustomAttributes (Type attributeType, bool inherit)
{
throw new NotSupportedException ();
}
public override string Name {
get {
throw new NotSupportedException ();
}
}
#endregion
#region implemented abstract members of Type
public override Type GetInterface (string name, bool ignoreCase)
{
throw new NotSupportedException ();
}
public override Type[] GetInterfaces ()
{
throw new NotSupportedException ();
}
public override Type GetElementType ()
{
throw new NotSupportedException ();
}
public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override EventInfo[] GetEvents (BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override FieldInfo GetField (string name, BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override FieldInfo[] GetFields (BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
throw new NotSupportedException ();
}
public override MethodInfo[] GetMethods (BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override Type GetNestedType (string name, BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override Type[] GetNestedTypes (BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override PropertyInfo[] GetProperties (BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
{
throw new NotSupportedException ();
}
protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
throw new NotSupportedException ();
}
protected override TypeAttributes GetAttributeFlagsImpl ()
{
throw new NotSupportedException ();
}
protected override bool HasElementTypeImpl ()
{
throw new NotSupportedException ();
}
protected override bool IsArrayImpl ()
{
throw new NotSupportedException ();
}
protected override bool IsByRefImpl ()
{
throw new NotSupportedException ();
}
protected override bool IsCOMObjectImpl ()
{
throw new NotSupportedException ();
}
protected override bool IsPointerImpl ()
{
throw new NotSupportedException ();
}
protected override bool IsPrimitiveImpl ()
{
throw new NotSupportedException ();
}
public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
{
throw new NotSupportedException ();
}
public override object InvokeMember (string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, string[] namedParameters)
{
throw new NotSupportedException ();
}
public override Assembly Assembly {
get {
throw new NotSupportedException ();
}
}
public override string AssemblyQualifiedName {
get {
throw new NotSupportedException ();
}
}
public override Type BaseType {
get {
throw new NotSupportedException ();
}
}
public override string FullName {
get {
throw new NotSupportedException ();
}
}
public override Guid GUID {
get {
throw new NotSupportedException ();
}
}
public override Module Module {
get {
throw new NotSupportedException ();
}
}
public override string Namespace {
get {
throw new NotSupportedException ();
}
}
public override Type UnderlyingSystemType {
get {
throw new NotSupportedException ();
}
}
#endregion
public void SetCustomAttribute (params object[] args)
{
throw new NotSupportedException ();
}
public void SetGenericParameterAttributes (GenericParameterAttributes genericParameterAttributes)
{
throw new NotSupportedException ();
}
public void SetInterfaceConstraints (params Type[] interfaceConstraints)
{
throw new NotSupportedException ();
}
public void SetBaseTypeConstraint (Type baseTypeConstraint)
{
throw new NotSupportedException ();
}
}
public class ConstructorBuilder : MethodBase
{
#region implemented abstract members of MemberInfo
@@ -1087,19 +803,6 @@ namespace System.Reflection.Emit
}
}
public class ParameterBuilder : ParameterInfo
{
public void SetConstant (object arg)
{
throw new NotSupportedException ();
}
public void SetCustomAttribute (params object[] args)
{
throw new NotSupportedException ();
}
}
public class EventBuilder
{
public void SetAddOnMethod (MethodBuilder mdBuilder)
@@ -1118,11 +821,4 @@ namespace System.Reflection.Emit
}
}
public class CustomAttributeBuilder
{
public CustomAttributeBuilder (params object[] args)
{
throw new NotSupportedException ();
}
}
}
@@ -187,13 +187,54 @@ namespace Mono.CompilerServices.SymbolWriter
public void DefineMethod (MonoSymbolFile file, int token)
{
var blocks = Blocks;
if (blocks.Length > 0) {
//
// When index is provided by user it can be inserted in
// any order but mdb format does not store its value. It
// uses stored order as the index instead.
//
var sorted = new List<CodeBlockEntry> (blocks.Length);
int max_index = 0;
for (int i = 0; i < blocks.Length; ++i) {
max_index = System.Math.Max (max_index, blocks [i].Index);
}
//
// When index is provided by user it can be inserted in
// any order but mdb format does not store its value. It
// uses store order instead as the index.
//
Array.Sort (blocks, (x, y) => x.Index.CompareTo (y.Index));
for (int i = 0; i < max_index; ++i) {
var scope_index = i + 1;
//
// Common fast path
//
if (i < blocks.Length && blocks [i].Index == scope_index) {
sorted.Add (blocks [i]);
continue;
}
bool found = false;
for (int ii = 0; ii < blocks.Length; ++ii) {
if (blocks [ii].Index == scope_index) {
sorted.Add (blocks [ii]);
found = true;
break;
}
}
if (found)
continue;
//
// Ideally this should never happen but with current design we can
// generate scope index for unreachable code before reachable code
//
sorted.Add (new CodeBlockEntry (scope_index, -1, CodeBlockEntry.Type.CompilerGenerated, 0));
}
blocks = sorted.ToArray ();
//for (int i = 0; i < blocks.Length; ++i) {
// if (blocks [i].Index - 1 != i)
// throw new ArgumentException ("CodeBlocks cannot be converted to mdb format");
//}
}
var entry = new MethodEntry (
file, _comp_unit.Entry, token, ScopeVariables,
@@ -221,7 +221,7 @@ namespace Mono.Data.Sqlite
case SQLiteDateFormats.UnixEpoch:
return ((long)(dateValue.Subtract(UnixEpoch).Ticks / TimeSpan.TicksPerSecond)).ToString();
default:
return dateValue.ToString(_datetimeFormats[7], CultureInfo.InvariantCulture);
return dateValue.ToString(_datetimeFormats[5], CultureInfo.InvariantCulture);
}
}
@@ -6,4 +6,4 @@ SqliteExceptionUnitTests.cs
SqliteParameterUnitTests.cs
SqliteFunctionTests.cs
Bug27864.cs
SqliteTests.cs
@@ -0,0 +1,102 @@
//
// SqliteTests.cs
//
// Authors:
// Marek Safar <[email protected]>
//
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Data;
using System.IO;
using System.Text;
using Mono.Data.Sqlite;
using NUnit.Framework;
namespace MonoTests.Mono.Data.Sqlite
{
[TestFixture]
public class SqliteTests
{
string _databasePath;
[SetUp]
public void Setup ()
{
var dataFolder = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "SqlTest");
_databasePath = Path.Combine (dataFolder, "database.db");
if (!Directory.Exists (dataFolder)) {
Directory.CreateDirectory (dataFolder);
}
File.Delete (_databasePath);
}
[TearDown]
public void TearDown ()
{
try {
File.Delete (_databasePath);
} catch {
}
}
[Test]
public void DateTimeConvert ()
{
var dateTime = new DateTime (2016, 9, 15, 12, 1, 53);
var guid = Guid.NewGuid ();
using (var connection = new SqliteConnection ("Data Source=" + _databasePath)) {
connection.Open ();
var sqlCreate = "CREATE TABLE TestTable (ID uniqueidentifier PRIMARY KEY, Modified datetime)";
using (var cmd = new SqliteCommand (sqlCreate, connection)) {
cmd.ExecuteNonQuery ();
}
var sqlInsert = "INSERT INTO TestTable (ID, Modified) VALUES (@id, @mod)";
using (var cmd = new SqliteCommand (sqlInsert, connection)) {
cmd.Parameters.Add (new SqliteParameter ("@id", guid));
cmd.Parameters.Add (new SqliteParameter ("@mod", dateTime));
cmd.ExecuteNonQuery ();
}
}
using (var connection = new SqliteConnection ("Data Source=" + _databasePath)) {
connection.Open ();
var sqlSelect = "SELECT * from TestTable";
using (var cmd = new SqliteCommand (sqlSelect, connection))
using (var reader = cmd.ExecuteReader ()) {
while (reader.Read ()) {
Assert.AreEqual (guid, reader.GetGuid (0), "#1");
Assert.AreEqual (dateTime, reader.GetDateTime (1), "#2");
}
}
}
}
}
}
@@ -430,6 +430,7 @@ public class Tests : TestsBase, ITest2
ss_recursive2 (1);
ss_recursive_chaotic ();
ss_fp_clobber ();
ss_no_frames ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
@@ -679,6 +680,25 @@ public class Tests : TestsBase, ITest2
public static void ss_fp_clobber_2 (double d) {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_no_frames () {
Action a = ss_no_frames_2;
var ar = a.BeginInvoke (null, null);
ar.AsyncWaitHandle.WaitOne ();
// Avoid waiting every time this runs
if (static_i == 56)
Thread.Sleep (200);
ss_no_frames_3 ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_no_frames_2 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_no_frames_3 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static bool is_even (int i) {
return i % 2 == 0;
@@ -890,6 +890,28 @@ public class DebuggerTests
req.Disable ();
}
[Test]
public void SingleSteppingNoFrames () {
//
// Test what happens when starting a single step operation on a thread
// with no managed frames
//
// Run a delegate on a tp thread
var e = run_until ("ss_no_frames_2");
var this_type = e.Thread.GetFrames ()[0].Method.DeclaringType;
this_type.SetValue (this_type.GetField ("static_i"), vm.CreateValue (56));
var thread = e.Thread;
var e2 = run_until ("ss_no_frames_3");
// The tp thread should be idle now
step_req = vm.CreateStepRequest (thread);
step_req.Depth = StepDepth.Over;
AssertThrows<Exception> (delegate {
step_req.Enable ();
});
}
[Test]
public void MethodEntryExit () {
run_until ("single_stepping");
@@ -1,14 +0,0 @@
thisdir = class/Mono.Security.Providers.DotNet
SUBDIRS =
include ../../build/rules.make
LIBRARY = Mono.Security.Providers.DotNet.dll
LIB_REFS = System Mono.Security
LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign
EXTRA_DISTFILES = README.md
include ../../build/library.make
$(the_lib): ../Mono.Security/Makefile
@@ -1,101 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{391EDD2B-85AC-4FCA-B607-AAD6C51E6799}</ProjectGuid>
<OutputType>Library</OutputType>
<NoWarn>1699,1030</NoWarn>
<OutputPath>./../../class/lib/net_4_x</OutputPath>
<IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<NoStdLib>True</NoStdLib>
<NoConfig>True</NoConfig>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>
</RootNamespace>
<AssemblyName>Mono.Security.Providers.DotNet</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>false</Optimize>
<DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>true</Optimize>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0,
Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This
is a problem to compile the Mono mscorlib.dll -->
<PropertyGroup>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="..\..\build\common\Consts.cs" />
<Compile Include="..\..\build\common\Locale.cs" />
<Compile Include=".\Mono.Security.Providers.DotNet\DotNetSslStreamImpl.cs" />
<Compile Include=".\Mono.Security.Providers.DotNet\DotNetTlsProvider.cs" />
<Compile Include=".\Properties\AssemblyInfo.cs" />␍ </ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PreBuildEvent>
<PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PreBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../corlib/corlib-net_4_x.csproj">
<Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>
<Name>corlib-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../System/System-net_4_x.csproj">
<Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>
<Name>System-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">
<Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>
<Name>Mono.Security-net_4_x</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
@@ -1,6 +0,0 @@
./Properties/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
./Mono.Security.Providers.DotNet/DotNetTlsProvider.cs
./Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs
@@ -1,317 +0,0 @@
//
// DotNetSslStreamImpl.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Threading.Tasks;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Security.Principal;
using System.Security.Cryptography;
using MSI = Mono.Security.Interface;
namespace Mono.Security.Providers.DotNet
{
class DotNetSslStreamImpl : MSI.IMonoSslStream
{
DotNetTlsProvider provider;
SslStream impl;
internal SslStream Impl {
get {
CheckDisposed ();
return impl;
}
}
public DotNetSslStreamImpl (
Stream innerStream, bool leaveInnerStreamOpen, DotNetTlsProvider provider,
RemoteCertificateValidationCallback userCertificateValidationCallback,
LocalCertificateSelectionCallback userCertificateSelectionCallback)
{
this.provider = provider;
impl = new SslStream (
innerStream, leaveInnerStreamOpen,
userCertificateValidationCallback,
userCertificateSelectionCallback);
}
public void AuthenticateAsClient (string targetHost)
{
Impl.AuthenticateAsClient (targetHost);
}
public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsClient (IAsyncResult asyncResult)
{
Impl.EndAuthenticateAsClient (asyncResult);
}
public void AuthenticateAsServer (X509Certificate serverCertificate)
{
Impl.AuthenticateAsServer (serverCertificate);
}
public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsServer (IAsyncResult asyncResult)
{
Impl.EndAuthenticateAsServer (asyncResult);
}
public Task AuthenticateAsClientAsync (string targetHost)
{
return Impl.AuthenticateAsClientAsync (targetHost);
}
public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
{
return Impl.AuthenticateAsServerAsync (serverCertificate);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public void Flush ()
{
Impl.Flush ();
}
public int Read (byte[] buffer, int offset, int count)
{
return Impl.Read (buffer, offset, count);
}
public void Write (byte[] buffer)
{
Impl.Write (buffer);
}
public void Write (byte[] buffer, int offset, int count)
{
Impl.Write (buffer, offset, count);
}
public IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginRead (buffer, offset, count, asyncCallback, asyncState);
}
public int EndRead (IAsyncResult asyncResult)
{
return Impl.EndRead (asyncResult);
}
public IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginWrite (buffer, offset, count, asyncCallback, asyncState);
}
public void EndWrite (IAsyncResult asyncResult)
{
Impl.EndWrite (asyncResult);
}
public TransportContext TransportContext {
get { throw new NotSupportedException (); }
}
public bool IsAuthenticated {
get { return Impl.IsAuthenticated; }
}
public bool IsMutuallyAuthenticated {
get { return Impl.IsMutuallyAuthenticated; }
}
public bool IsEncrypted {
get { return Impl.IsEncrypted; }
}
public bool IsSigned {
get { return Impl.IsSigned; }
}
public bool IsServer {
get { return Impl.IsServer; }
}
public CipherAlgorithmType CipherAlgorithm {
get { return Impl.CipherAlgorithm; }
}
public int CipherStrength {
get { return Impl.CipherStrength; }
}
public HashAlgorithmType HashAlgorithm {
get { return Impl.HashAlgorithm; }
}
public int HashStrength {
get { return Impl.HashStrength; }
}
public ExchangeAlgorithmType KeyExchangeAlgorithm {
get { return Impl.KeyExchangeAlgorithm; }
}
public int KeyExchangeStrength {
get { return KeyExchangeStrength; }
}
public bool CanRead {
get { return Impl.CanRead; }
}
public bool CanTimeout {
get { return Impl.CanTimeout; }
}
public bool CanWrite {
get { return Impl.CanWrite; }
}
public long Length {
get { return Impl.Length; }
}
public long Position {
get { return Impl.Position; }
}
public void SetLength (long value)
{
Impl.SetLength (value);
}
public AuthenticatedStream AuthenticatedStream {
get { return Impl; }
}
public int ReadTimeout {
get { return Impl.ReadTimeout; }
set { Impl.ReadTimeout = value; }
}
public int WriteTimeout {
get { return Impl.WriteTimeout; }
set { Impl.WriteTimeout = value; }
}
public bool CheckCertRevocationStatus {
get { return Impl.CheckCertRevocationStatus; }
}
public X509Certificate InternalLocalCertificate {
get {
try {
return LocalCertificate;
} catch {
return null;
}
}
}
public X509Certificate LocalCertificate {
get { return Impl.LocalCertificate; }
}
public X509Certificate RemoteCertificate {
get { return Impl.RemoteCertificate; }
}
public SslProtocols SslProtocol {
get { return Impl.SslProtocol; }
}
MSI.MonoTlsProvider MSI.IMonoSslStream.Provider {
get { return provider; }
}
MSI.MonoTlsConnectionInfo MSI.IMonoSslStream.GetConnectionInfo ()
{
return null;
}
void CheckDisposed ()
{
if (impl == null)
throw new ObjectDisposedException ("MonoSslStream");
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected void Dispose (bool disposing)
{
if (impl != null && disposing) {
impl.Dispose ();
impl = null;
}
}
}
}
@@ -1,118 +0,0 @@
//
// MonoDefaultTlsProvider.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using Mono.Security.Interface;
namespace Mono.Security.Providers.DotNet
{
/*
* This provider only uses the public .NET APIs from System.dll.
*
* It is primarily intended for testing.
*/
public class DotNetTlsProvider : MonoTlsProvider
{
static readonly Guid id = new Guid ("3a7b3a26-0dbd-4572-a5b8-fdce766bf0dd");
public override Guid ID {
get { return id; }
}
public override string Name {
get { return "dotnet"; }
}
public override bool SupportsSslStream {
get { return true; }
}
public override bool SupportsConnectionInfo {
get { return false; }
}
public override bool SupportsMonoExtensions {
get { return false; }
}
internal override bool SupportsTlsContext {
get { return false; }
}
public override SslProtocols SupportedProtocols {
get { return (SslProtocols)ServicePointManager.SecurityProtocol; }
}
public override IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings = null)
{
if (settings != null)
throw new NotSupportedException ("Mono-specific API Extensions not available.");
RemoteCertificateValidationCallback validation_callback = null;
LocalCertificateSelectionCallback selection_callback = null;
if (settings != null) {
validation_callback = ConvertCallback (settings.RemoteCertificateValidationCallback);
selection_callback = ConvertCallback (settings.ClientCertificateSelectionCallback);
}
return new DotNetSslStreamImpl (innerStream, leaveInnerStreamOpen, this, validation_callback, selection_callback);
}
internal override IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, TlsProtocols protocolFlags,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
MonoTlsSettings settings)
{
throw new NotSupportedException ();
}
internal static RemoteCertificateValidationCallback ConvertCallback (MonoRemoteCertificateValidationCallback callback)
{
if (callback == null)
return null;
return (s, c, ch, e) => callback (null, c, ch, (MonoSslPolicyErrors)e);
}
internal static LocalCertificateSelectionCallback ConvertCallback (MonoLocalCertificateSelectionCallback callback)
{
if (callback == null)
return null;
return (s, t, lc, rc, ai) => callback (t, lc, rc, ai);
}
}
}
@@ -1 +0,0 @@
See mcs/class/Mono.Security.Providers.NewSystemSource/README.md for a detailed README.
@@ -1,24 +0,0 @@
thisdir = class/Mono.Security.Providers.NewSystemSource
SUBDIRS =
include ../../build/rules.make
LIB_REFS = System
LIBRARY = Mono.Security.Providers.NewSystemSource.dll
LIB_MCS_FLAGS = -d:SECURITY_DEP \
-unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:MONO -d:FEATURE_PAL -d:MONO_FEATURE_NEW_TLS \
-d:MONO_FEATURE_NEW_SYSTEM_SOURCE -d:DISABLE_CAS_USE
ifdef MOBILE_PROFILE
LIB_REFS += Mono.Security
else
LIB_REFS += MonoSecurity=Mono.Security
LIB_MCS_FLAGS += -d:MONO_SECURITY_ALIAS
endif
EXTRA_DISTFILES = README.md
include ../../build/library.make
$(the_lib): ../Mono.Security/Makefile
@@ -1,126 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}</ProjectGuid>
<OutputType>Library</OutputType>
<NoWarn>1699,1030</NoWarn>
<OutputPath>./../../class/lib/net_4_x</OutputPath>
<IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<NoStdLib>True</NoStdLib>
<NoConfig>True</NoConfig>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>
</RootNamespace>
<AssemblyName>Mono.Security.Providers.NewSystemSource</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>false</Optimize>
<DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP;MONO;FEATURE_PAL;MONO_FEATURE_NEW_TLS;MONO_FEATURE_NEW_SYSTEM_SOURCE;DISABLE_CAS_USE;MONO_SECURITY_ALIAS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>true</Optimize>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP;MONO;FEATURE_PAL;MONO_FEATURE_NEW_TLS;MONO_FEATURE_NEW_SYSTEM_SOURCE;DISABLE_CAS_USE;MONO_SECURITY_ALIAS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0,
Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This
is a problem to compile the Mono mscorlib.dll -->
<PropertyGroup>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="..\..\build\common\Consts.cs" />
<Compile Include="..\..\build\common\Locale.cs" />
<Compile Include="..\..\build\common\SR.cs" />
<Compile Include="..\referencesource\mscorlib\InternalApis\NDP_Common\inc\PinnableBufferCache.cs" />
<Compile Include="..\referencesource\System\net\System\Net\_LazyAsyncResult.cs" />
<Compile Include="..\referencesource\System\net\System\Net\_LoggingObject.cs" />
<Compile Include="..\referencesource\System\net\System\Net\_NTAuthentication.cs" />
<Compile Include="..\referencesource\System\net\System\Net\_SecureChannel.cs" />
<Compile Include="..\referencesource\System\net\System\Net\_SslSessionsCache.cs" />
<Compile Include="..\referencesource\System\net\System\Net\Logging.cs" />
<Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_FixedSizeReader.cs" />
<Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_HelperAsyncResults.cs" />
<Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_SslState.cs" />
<Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_SslStream.cs" />
<Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\SslStream.cs" />
<Compile Include="..\System\Mono.Net.Security\CallbackHelpers.cs" />
<Compile Include="..\System\Mono.Net.Security\IMonoTlsProvider.cs" />
<Compile Include="..\System\Mono.Net.Security\MonoTlsProviderFactory.cs" />
<Compile Include="..\System\Mono.Net.Security\MonoTlsProviderWrapper.cs" />
<Compile Include="..\System\ReferenceSources\_SecureChannel.cs" />
<Compile Include="..\System\ReferenceSources\_SslState.cs" />
<Compile Include="..\System\ReferenceSources\_SslStream.cs" />
<Compile Include="..\System\ReferenceSources\Internal.cs" />
<Compile Include="..\System\ReferenceSources\SR.cs" />
<Compile Include="..\System\ReferenceSources\SR2.cs" />
<Compile Include="..\System\ReferenceSources\SslStream.cs" />
<Compile Include="..\System\ReferenceSources\SSPIConfiguration.cs" />
<Compile Include="..\System\ReferenceSources\SSPISafeHandles.cs" />
<Compile Include="..\System\ReferenceSources\SSPIWrapper.cs" />
<Compile Include=".\Properties\AssemblyInfo.cs" />␍ </ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PreBuildEvent>
<PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PreBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../corlib/corlib-net_4_x.csproj">
<Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>
<Name>corlib-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../System/System-net_4_x.csproj">
<Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>
<Name>System-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">
<Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>
<Name>Mono.Security-net_4_x</Name>
<Aliases>MonoSecurity</Aliases> </ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
@@ -1,33 +0,0 @@
./Properties/AssemblyInfo.cs
../../build/common/SR.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
../referencesource/System/net/System/Net/Logging.cs
../referencesource/System/net/System/Net/_SslSessionsCache.cs
../referencesource/System/net/System/Net/_LazyAsyncResult.cs
../referencesource/System/net/System/Net/_LoggingObject.cs
../referencesource/System/net/System/Net/_NTAuthentication.cs
../referencesource/System/net/System/Net/_SecureChannel.cs
../referencesource/System/net/System/Net/SecureProtocols/SslStream.cs
../referencesource/System/net/System/Net/SecureProtocols/_SslState.cs
../referencesource/System/net/System/Net/SecureProtocols/_SslStream.cs
../referencesource/System/net/System/Net/SecureProtocols/_FixedSizeReader.cs
../referencesource/System/net/System/Net/SecureProtocols/_HelperAsyncResults.cs
../referencesource/mscorlib/InternalApis/NDP_Common/inc/PinnableBufferCache.cs
../System/ReferenceSources/SR.cs
../System/ReferenceSources/SR2.cs
../System/ReferenceSources/Internal.cs
../System/ReferenceSources/SSPIWrapper.cs
../System/ReferenceSources/SSPISafeHandles.cs
../System/ReferenceSources/SslStream.cs
../System/ReferenceSources/_SslState.cs
../System/ReferenceSources/_SslStream.cs
../System/ReferenceSources/_SecureChannel.cs
../System/ReferenceSources/SSPIConfiguration.cs
../System/Mono.Net.Security/CallbackHelpers.cs
../System/Mono.Net.Security/IMonoTlsProvider.cs
../System/Mono.Net.Security/MonoTlsProviderFactory.cs
../System/Mono.Net.Security/MonoTlsProviderWrapper.cs
@@ -1,48 +0,0 @@
//
// AssemblyInfo.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Reflection;
using System.Resources;
using System.Security;
using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about the system assembly
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: AssemblyCompany ("MONO development team")]
[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
[assembly: AssemblyDescription ("Mono.Security.Providers.NewSystemSource.dll")]
[assembly: AssemblyProduct ("MONO CLI")]
[assembly: AssemblyTitle ("Mono.Security.Providers.NewSystemSource.dll")]
[assembly: CLSCompliant (true)]
[assembly: ComVisible (false)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
@@ -1,95 +0,0 @@
Mono.Security.Interface / Mono.Security.Providers
=================================================
This is not a public API yet, but will eventually become public.
Mono.Security.Interface
-----------------------
`Mono.Security.Interface` provides an abstraction layer for the TLS
APIs that are currently being used by Mono's class libraries.
The main API entry points are `MonoTlsProviderFactory.GetProvider()`
and `MonoTlsProviderFactory.InstallProvider()`.
Mono.Net.Security
-----------------
`Mono.Net.Security` provides the internal implementation and lives
inside `System.dll` as private and internal APIs. `Mono.Security.dll`
uses reflection to access these.
On Mobile, the `Mono.Security.Interface` APIs are included as public
APIs in `System.dll`.
Mono.Security.Providers
-----------------------
Implementations of the `Mono.Security.Interface.MonoTlsProvider` class
to provide TLS functionality.
The default provider is inside `System.dll` - it will be used automatically
if you don't explicitly install a custom provider, so simply call
`MonoTlsProviderFactory.GetProvider()` to use it.
* DotNet:
Provides the default `SslStream` implementation from `System.dll`, only using
public .NET types.
* NewSystemSource:
Compiles several referencesource files which would normally live inside
`System.dll` if we compiled it with their `SslStream` implementation.
This allows to keep the code in `System.dll` as-is, while still providing the
new `SslStream`, which will be required by the new TLS code.
`System.dll` needs to make its internals visible and we're using several compiler /
external alias tricks in here to make this work.
In this configuration, `MONO_SYSTEM_ALIAS`, `MONO_FEATURE_NEW_TLS` and
`MONO_FEATURE_NEW_SYSTEM_SOURCE` (defining conditional for this configuration)
are defined. We do not define `MONO_X509_ALIAS here`.
The `Mono.Security.Providers.DotNet` and `Mono.Security.Providers.NewSystemSource` directory is currently
enabled in the top-level `Makefile`, but the resulting binaries should only be used to test the new TLS
code and not shipped as stable APIs.
Pending changes
---------------
This code is not actually being used in `System.dll` yet. I have some
local changes which will switch the existing code in `WebClient`,
`SmptClient` and `FtpWebRequest` over, but these need to be carefully
tested.
At the moment, this work branch only provides new code and build
changes, which shuffle some stuff around. There are also several
new files which are conditional and not actually being built by
default.
Build Configurations
--------------------
* Normal build:
Builds everything as before with some new APIs added, but without
modifying any existing functionality.
* Build with the `newtls` profile:
Builds `System.dll` with the new `SslStream` implementation from the
referencesource. This is currently a "build then throw away" profile
and not enabled from the top-level Makefile. The resulting `System.dll`
won't actually work at runtime since it's missing the new TLS code;
building it helps find problems and ensures that it will actually
be possible to build this once we deploy it.
* Mono.Security.Providers:
The new TLS code requires the newly built `System` and `Mono.Security.Providers.NewSystemSource`
from this branch installed in the system. It is recommended to install it
into a custom prefix and set that as custom runtime in Xamarin Studio.
Last changed March 07th, 2015,
Martin Baulig <martin.baulig@xamarin.com>
@@ -1,12 +0,0 @@
thisdir = class/Mono.Security.Providers.NewTls
SUBDIRS =
include ../../build/rules.make
LIBRARY = Mono.Security.Providers.NewTls.dll
LIB_REFS = System NewSystemSource=Mono.Security.Providers.NewSystemSource Mono.Security
LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign
include ../../build/library.make
$(the_lib): ../Mono.Security/Makefile
@@ -1,111 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C8B8E524-BB3A-44E2-8C22-E3313E9F477C}</ProjectGuid>
<OutputType>Library</OutputType>
<NoWarn>1699,1030</NoWarn>
<OutputPath>./../../class/lib/net_4_x</OutputPath>
<IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<NoStdLib>True</NoStdLib>
<NoConfig>True</NoConfig>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>
</RootNamespace>
<AssemblyName>Mono.Security.Providers.NewTls</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>false</Optimize>
<DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>true</Optimize>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0,
Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This
is a problem to compile the Mono mscorlib.dll -->
<PropertyGroup>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="..\..\build\common\Consts.cs" />
<Compile Include="..\..\build\common\Locale.cs" />
<Compile Include="..\..\build\common\SR.cs" />
<Compile Include=".\Mono.Security.Providers.NewTls\ITlsConfiguration.cs" />
<Compile Include=".\Mono.Security.Providers.NewTls\ITlsContext.cs" />
<Compile Include=".\Mono.Security.Providers.NewTls\MonoNewTlsStream.cs" />
<Compile Include=".\Mono.Security.Providers.NewTls\MonoNewTlsStreamFactory.cs" />
<Compile Include=".\Mono.Security.Providers.NewTls\NewTlsProvider.cs" />
<Compile Include=".\Mono.Security.Providers.NewTls\TlsContextWrapper.cs" />
<Compile Include=".\Mono.Security.Providers.NewTls\TlsProviderFactory.cs" />
<Compile Include=".\Properties\AssemblyInfo.cs" />␍ </ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PreBuildEvent>
<PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PreBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../corlib/corlib-net_4_x.csproj">
<Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>
<Name>corlib-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../System/System-net_4_x.csproj">
<Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>
<Name>System-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">
<Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>
<Name>Mono.Security-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource-net_4_x.csproj">
<Project>{0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}</Project>
<Name>Mono.Security.Providers.NewSystemSource-net_4_x</Name>
<Aliases>NewSystemSource</Aliases> </ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
@@ -1,13 +0,0 @@
./Properties/AssemblyInfo.cs
../../build/common/SR.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
./Mono.Security.Providers.NewTls/ITlsConfiguration.cs
./Mono.Security.Providers.NewTls/ITlsContext.cs
./Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
./Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
./Mono.Security.Providers.NewTls/NewTlsProvider.cs
./Mono.Security.Providers.NewTls/TlsContextWrapper.cs
./Mono.Security.Providers.NewTls/TlsProviderFactory.cs
@@ -1,93 +0,0 @@
//
// MonoNewTlsStream.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern alias NewSystemSource;
using EncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
using LocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
using RemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
using SslStream = NewSystemSource::System.Net.Security.SslStream;
using System;
using System.IO;
using System.Threading.Tasks;
using MSI = Mono.Security.Interface;
using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
using System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
public class MonoNewTlsStream : SslStream, MSI.IMonoSslStream
{
MSI.MonoTlsProvider provider;
internal MonoNewTlsStream (Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
: this (innerStream, false, provider, settings)
{
}
internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
: base (innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
{
this.provider = provider;
}
public MSI.MonoTlsProvider Provider {
get { return provider; }
}
new public bool IsClosed {
get { return base.IsClosed; }
}
public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
{
return GetMonoConnectionInfo ();
}
public Task Shutdown ()
{
return Task.Factory.FromAsync ((state, result) => BeginShutdown (state, result), EndShutdown, null);
}
public Task RequestRenegotiation ()
{
return Task.Factory.FromAsync ((state, result) => BeginRenegotiate (state, result), EndRenegotiate, null);
}
X509Certificate MSI.IMonoSslStream.InternalLocalCertificate {
get { return InternalLocalCertificate; }
}
XAuthenticatedStream MSI.IMonoSslStream.AuthenticatedStream {
get { return this; }
}
}
}
@@ -1,91 +0,0 @@
//
// MonoNewTlsStreamFactory.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern alias NewSystemSource;
using XEncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
using XSslPolicyErrors = NewSystemSource::System.Net.Security.SslPolicyErrors;
using XLocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
using XRemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
using System;
using System.IO;
using System.Net.Security;
using System.Security.Authentication;
using Mono.Security.Interface;
using PSSCX = System.Security.Cryptography.X509Certificates;
using SSCX = System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
public static class MonoNewTlsStreamFactory
{
internal static IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsProvider provider, MonoTlsSettings settings = null)
{
return new MonoNewTlsStream (innerStream, leaveInnerStreamOpen, provider, settings);
}
public static MonoNewTlsStream CreateServer (
Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
SSCX.X509Certificate serverCertificate, bool clientCertificateRequired,
SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
try {
stream.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
} catch (Exception ex) {
var tlsEx = stream.LastError;
if (tlsEx != null)
throw new AggregateException (ex, tlsEx);
throw;
}
return stream;
}
public static MonoNewTlsStream CreateClient (
Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
string targetHost, PSSCX.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
try {
stream.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
} catch (Exception ex) {
var tlsEx = stream.LastError;
if (tlsEx != null)
throw new AggregateException (ex, tlsEx);
throw;
}
return stream;
}
}
}
@@ -1,95 +0,0 @@
//
// NewTlsProvider.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern alias NewSystemSource;
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using MSI = Mono.Security.Interface;
using MX = Mono.Security.X509;
using PSSCX = System.Security.Cryptography.X509Certificates;
using SSCX = System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
public class NewTlsProvider : MSI.MonoTlsProvider
{
static readonly Guid id = new Guid ("e5ff34f1-8b7a-4aa6-aff9-24719d709693");
public override Guid ID {
get { return id; }
}
public override string Name {
get { return "newtls"; }
}
public override bool SupportsSslStream {
get { return true; }
}
public override bool SupportsConnectionInfo {
get { return true; }
}
public override bool SupportsMonoExtensions {
get { return true; }
}
internal override bool SupportsTlsContext {
get { return true; }
}
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
}
public override MSI.IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MSI.MonoTlsSettings settings = null)
{
return MonoNewTlsStreamFactory.CreateSslStream (innerStream, leaveInnerStreamOpen, this, settings);
}
internal override MSI.IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
SSCX.X509Certificate serverCertificate, PSSCX.X509CertificateCollection clientCertificates,
bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
MSI.MonoTlsSettings settings)
{
var config = TlsProviderFactory.CreateTlsConfiguration (
hostname, serverMode, protocolFlags, serverCertificate,
remoteCertRequired, settings);
return new TlsContextWrapper (config, serverMode);
}
}
}
@@ -1,221 +0,0 @@
//
// TlsContextWrapper.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern alias NewSystemSource;
using System;
using System.Security.Cryptography;
using SSCX = System.Security.Cryptography.X509Certificates;
using PSSCX = System.Security.Cryptography.X509Certificates;
using MSI = Mono.Security.Interface;
using MX = Mono.Security.X509;
namespace Mono.Security.Providers.NewTls
{
class TlsContextWrapper : IDisposable, MSI.IMonoTlsContext
{
ITlsConfiguration config;
ITlsContext context;
bool serverMode;
public TlsContextWrapper (ITlsConfiguration config, bool serverMode)
{
this.config = config;
this.serverMode = serverMode;
}
public bool IsServer {
get { return serverMode; }
}
public bool IsValid {
get { return context != null && context.IsValid; }
}
public void Initialize (MSI.IMonoTlsEventSink eventSink)
{
if (context != null)
throw new InvalidOperationException ();
context = TlsProviderFactory.CreateTlsContext (config, serverMode, eventSink);
}
void Clear ()
{
if (context != null) {
context.Dispose ();
context = null;
}
}
public ITlsConfiguration Configuration {
get {
if (config == null)
throw new ObjectDisposedException ("TlsConfiguration");
return config;
}
}
public ITlsContext Context {
get {
if (!IsValid)
throw new ObjectDisposedException ("TlsContext");
return context;
}
}
public bool HasCredentials {
get { return Configuration.HasCredentials; }
}
public void SetCertificate (SSCX.X509Certificate certificate, AsymmetricAlgorithm privateKey)
{
var monoCert = new MX.X509Certificate (certificate.GetRawCertData ());
Configuration.SetCertificate (monoCert, privateKey);
}
public int GenerateNextToken (MSI.IBufferOffsetSize incoming, out MSI.IBufferOffsetSize outgoing)
{
var input = incoming != null ? new MSI.TlsBuffer (BOSWrapper.Wrap (incoming)) : null;
var output = new MSI.TlsMultiBuffer ();
var retval = Context.GenerateNextToken (input, output);
if (output.IsEmpty)
outgoing = null;
outgoing = BOSWrapper.Wrap (output.StealBuffer ());
return (int)retval;
}
public int EncryptMessage (ref MSI.IBufferOffsetSize incoming)
{
var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
var retval = Context.EncryptMessage (ref buffer);
incoming = BOSWrapper.Wrap (buffer.GetRemaining ());
return (int)retval;
}
public int DecryptMessage (ref MSI.IBufferOffsetSize incoming)
{
var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
var retval = Context.DecryptMessage (ref buffer);
incoming = buffer != null ? BOSWrapper.Wrap (buffer.GetRemaining ()) : null;
return (int)retval;
}
class BOSWrapper : MSI.IBufferOffsetSize
{
public byte[] Buffer {
get;
private set;
}
public int Offset {
get;
private set;
}
public int Size {
get;
private set;
}
BOSWrapper (byte[] buffer, int offset, int size)
{
Buffer = buffer;
Offset = offset;
Size = size;
}
public static BOSWrapper Wrap (MSI.IBufferOffsetSize bos)
{
return bos != null ? new BOSWrapper (bos.Buffer, bos.Offset, bos.Size) : null;
}
}
public byte[] CreateCloseNotify ()
{
return Context.CreateAlert (new MSI.Alert (MSI.AlertLevel.Warning, MSI.AlertDescription.CloseNotify));
}
public byte[] CreateHelloRequest ()
{
return Context.CreateHelloRequest ();
}
public SSCX.X509Certificate GetRemoteCertificate (out PSSCX.X509CertificateCollection remoteCertificateStore)
{
MX.X509CertificateCollection monoCollection;
var remoteCert = Context.GetRemoteCertificate (out monoCollection);
if (remoteCert == null) {
remoteCertificateStore = null;
return null;
}
remoteCertificateStore = new PSSCX.X509CertificateCollection ();
foreach (var cert in monoCollection) {
remoteCertificateStore.Add (new PSSCX.X509Certificate2 (cert.RawData));
}
return new PSSCX.X509Certificate2 (remoteCert.RawData);
}
public bool VerifyRemoteCertificate ()
{
return Context.VerifyRemoteCertificate ();
}
public Exception LastError {
get {
if (context != null)
return context.LastError;
return null;
}
}
public bool ReceivedCloseNotify {
get {
return Context.ReceivedCloseNotify;
}
}
public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
{
return Context.ConnectionInfo;
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
void Dispose (bool disposing)
{
Clear ();
}
}
}
@@ -1,97 +0,0 @@
//
// TlsProviderFactory.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015-2016 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern alias NewSystemSource;
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using MSI = Mono.Security.Interface;
using MX = Mono.Security.X509;
using PSSCX = System.Security.Cryptography.X509Certificates;
using SSCX = System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
static class TlsProviderFactory
{
const string assemblyName = "Mono.Security.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2";
const string tlsConfigTypeName = "Mono.Security.NewTls.TlsConfiguration";
const string tlsContextTypeName = "Mono.Security.NewTls.TlsContext";
static object CreateInstance (string typeName, object[] args)
{
var type = Type.GetType (typeName + ", " + assemblyName);
return Activator.CreateInstance (type, args);
}
internal static ITlsConfiguration CreateTlsConfiguration (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
SSCX.X509Certificate serverCertificate, bool remoteCertRequired,
MSI.MonoTlsSettings settings)
{
object[] args;
ITlsConfiguration config;
if (serverMode) {
var cert = (PSSCX.X509Certificate2)serverCertificate;
var monoCert = new MX.X509Certificate (cert.RawData);
args = new object[] {
(MSI.TlsProtocols)protocolFlags,
(MSI.MonoTlsSettings)settings,
monoCert,
cert.PrivateKey
};
} else {
args = new object[] {
(MSI.TlsProtocols)protocolFlags,
(MSI.MonoTlsSettings)settings,
hostname
};
}
config = (ITlsConfiguration)CreateInstance (tlsConfigTypeName, args);
if (serverMode && remoteCertRequired)
config.AskForClientCertificate = true;
return config;
}
internal static ITlsContext CreateTlsContext (
ITlsConfiguration config, bool serverMode,
MSI.IMonoTlsEventSink eventSink)
{
return (ITlsContext)CreateInstance (
tlsContextTypeName,
new object[] { config, serverMode, eventSink });
}
}
}
@@ -1,47 +0,0 @@
//
// AssemblyInfo.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Reflection;
using System.Resources;
using System.Security;
using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about the system assembly
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: AssemblyCompany ("Xamarin")]
[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
[assembly: AssemblyDescription ("Mono.Security.Providers.NewTls.dll")]
[assembly: AssemblyProduct ("MONO CLI")]
[assembly: AssemblyTitle ("Mono.Security.Providers.NewTls.dll")]
[assembly: CLSCompliant (false)]
[assembly: ComVisible (false)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: InternalsVisibleTo ("Mono.Security.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
@@ -1,7 +0,0 @@
Properties/AssemblyInfo.cs
Mono.Security.Providers.NewTls/ITlsConfiguration.cs
Mono.Security.Providers.NewTls/ITlsContext.cs
Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
@@ -1 +0,0 @@
#include mobile_Mono.Security.Providers.NewTls.dll.sources
@@ -1,167 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E485E885-59B1-4081-BC66-56AAAFD8771A}</ProjectGuid>
<OutputType>Library</OutputType>
<NoWarn>1699,1030</NoWarn>
<OutputPath>./../../class/lib/net_4_x</OutputPath>
<IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<NoStdLib>True</NoStdLib>
<NoConfig>True</NoConfig>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>
</RootNamespace>
<AssemblyName>Mono.Security.Providers.OldTls</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>false</Optimize>
<DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<NoWarn>1699,1030</NoWarn>
<Optimize>true</Optimize>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0,
Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This
is a problem to compile the Mono mscorlib.dll -->
<PropertyGroup>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="..\..\build\common\Consts.cs" />
<Compile Include="..\..\build\common\Locale.cs" />
<Compile Include="..\..\build\common\MonoTODOAttribute.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Cryptography\MD5SHA1.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Cryptography\TlsHMAC.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientCertificate.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientCertificateVerify.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientFinished.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientHello.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientKeyExchange.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificate.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificateRequest.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerFinished.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerHello.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerHelloDone.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerKeyExchange.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientCertificate.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientCertificateVerify.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientFinished.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientHello.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientKeyExchange.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerCertificate.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerCertificateRequest.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerFinished.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerHello.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerHelloDone.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerKeyExchange.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake\ClientCertificateType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake\HandshakeMessage.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake\HandshakeType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\Alert.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherAlgorithmType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherSuite.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherSuiteCollection.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherSuiteFactory.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ClientContext.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ClientRecordProtocol.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ClientSessionCache.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ContentType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\Context.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\DebugHelper.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ExchangeAlgorithmType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\HandshakeState.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\HashAlgorithmType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\HttpsClientStream.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\RecordProtocol.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\RSASslSignatureDeformatter.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\RSASslSignatureFormatter.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SecurityCompressionType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SecurityParameters.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SecurityProtocolType.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ServerContext.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ServerRecordProtocol.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslCipherSuite.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslClientStream.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslHandshakeHash.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslServerStream.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslStreamBase.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsCipherSuite.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsClientSettings.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsException.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsServerSettings.cs" />
<Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsStream.cs" />
<Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\AuthorityKeyIdentifierExtension.cs" />
<Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\ExtendedKeyUsageExtension.cs" />
<Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\GeneralNames.cs" />
<Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\NetscapeCertTypeExtension.cs" />
<Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\SubjectAltNameExtension.cs" />
<Compile Include="..\System\Mono.Net.Security\LegacySslStream.cs" />
<Compile Include=".\Mono.Security.Providers.OldTls\OldTlsProvider.cs" />
<Compile Include=".\Properties\AssemblyInfo.cs" />␍ </ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PreBuildEvent>
<PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PreBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../corlib/corlib-net_4_x.csproj">
<Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>
<Name>corlib-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../System/System-net_4_x.csproj">
<Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>
<Name>System-net_4_x</Name>
</ProjectReference>
<ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">
<Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>
<Name>Mono.Security-net_4_x</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
@@ -1,87 +0,0 @@
//
// OldTlsProvider.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using Mono.Security.Interface;
using MNS = Mono.Net.Security;
namespace Mono.Security.Providers.OldTls
{
public class OldTlsProvider : MonoTlsProvider
{
static readonly Guid id = new Guid ("cf8baa0d-c6ed-40ae-b512-dec8d097e9af");
public override Guid ID {
get { return id; }
}
public override string Name {
get { return "old"; }
}
public override bool SupportsSslStream {
get { return true; }
}
public override bool SupportsMonoExtensions {
get { return false; }
}
public override bool SupportsConnectionInfo {
get { return false; }
}
internal override bool SupportsTlsContext {
get { return false; }
}
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls; }
}
public override IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings = null)
{
var impl = new MNS.Private.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings);
return new MNS.Private.MonoSslStreamImpl (impl);
}
internal override IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, TlsProtocols protocolFlags,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
MonoTlsSettings settings)
{
throw new NotSupportedException ();
}
}
}
@@ -66,8 +66,3 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo ("System, PublicKey=00000000000000000400000000000000")]
#endif
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Xamarin.BoringTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000099dd12eda85767ae6f06023ee28e711c7e5a212462095c83868c29db75eddf6d8e296e03824c14fedd5f55553fed0b6173be3cc985a4b7f9fb7c83ccff8ba3938563b3d1f45a81122f12a1bcb73edcaad61a8456c7595a6da5184b4dd9d10f011b949ef1391fccfeab1ba62aa51c267ef8bd57ef1b6ba5a4c515d0badb81a78f")]
@@ -92,7 +92,6 @@
<Compile Include=".\Mono.Security.Interface\HashAlgorithmType.cs" />
<Compile Include=".\Mono.Security.Interface\IBufferOffsetSize.cs" />
<Compile Include=".\Mono.Security.Interface\IMonoSslStream.cs" />
<Compile Include=".\Mono.Security.Interface\IMonoTlsContext.cs" />
<Compile Include=".\Mono.Security.Interface\IMonoTlsEventSink.cs" />
<Compile Include=".\Mono.Security.Interface\MonoTlsConnectionInfo.cs" />
<Compile Include=".\Mono.Security.Interface\MonoTlsProvider.cs" />
@@ -103,13 +103,6 @@ namespace Mono.Security.Interface
* Internal use only.
*/
ValidationResult ValidateCertificate (string targetHost, bool serverMode, X509Certificate leaf, X509Chain chain);
/*
* On OS X and Mobile, the @chain will be initialized with the @certificates, but not actually built.
*/
bool InvokeSystemValidator (
string targetHost, bool serverMode, X509CertificateCollection certificates,
X509Chain chain, ref MonoSslPolicyErrors errors, ref int status11);
}
public static class CertificateValidationHelper
@@ -148,17 +141,23 @@ namespace Mono.Security.Interface
/*
* Internal API, intended to be used by MonoTlsProvider implementations.
*/
internal static ICertificateValidator2 GetInternalValidator (MonoTlsSettings settings, MonoTlsProvider provider)
{
return (ICertificateValidator2)NoReflectionHelper.GetInternalValidator (provider, settings);
}
[Obsolete ("Use GetInternalValidator")]
internal static ICertificateValidator2 GetDefaultValidator (MonoTlsSettings settings, MonoTlsProvider provider)
{
return (ICertificateValidator2)NoReflectionHelper.GetDefaultCertificateValidator (provider, settings);
return GetInternalValidator (settings, provider);
}
/*
* Use this overloaded version in user code.
*/
public static ICertificateValidator GetValidator (MonoTlsSettings settings, MonoTlsProvider provider = null)
public static ICertificateValidator GetValidator (MonoTlsSettings settings)
{
return GetDefaultValidator (settings, provider);
return (ICertificateValidator)NoReflectionHelper.GetDefaultValidator (settings);
}
}
}
@@ -31,6 +31,7 @@ namespace Mono.Security.Interface
/// <summary>
/// RFC 2246 A.5
/// </summary>
[CLSCompliant (false)]
public enum CipherSuiteCode : ushort
{
TLS_NULL_WITH_NULL_NULL = 0x0000,
@@ -29,6 +29,7 @@ namespace Mono.Security.Interface
{
public class MonoTlsConnectionInfo
{
[CLSCompliant (false)]
public CipherSuiteCode CipherSuiteCode {
get; set;
}
@@ -49,6 +50,10 @@ namespace Mono.Security.Interface
get; set;
}
public string PeerDomainName {
get; set;
}
public override string ToString ()
{
return string.Format ("[MonoTlsConnectionInfo: {0}:{1}]", ProtocolVersion, CipherSuiteCode);
@@ -145,14 +145,6 @@ namespace Mono.Security.Interface
#endregion
#region Certificate Validation
/*
* Allows a TLS provider to provide a custom system certificiate validator.
*/
internal virtual bool HasCustomSystemCertificateValidator {
get { return false; }
}
/*
* If @serverMode is true, then we're a server and want to validate a certificate
* that we received from a client.
@@ -162,32 +154,10 @@ namespace Mono.Security.Interface
* Returns `true` if certificate validation has been performed and `false` to invoke the
* default system validator.
*/
internal virtual bool InvokeSystemCertificateValidator (
internal abstract bool ValidateCertificate (
ICertificateValidator2 validator, string targetHost, bool serverMode,
X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain,
out bool success, ref MonoSslPolicyErrors errors, ref int status11)
{
throw new InvalidOperationException ();
}
#endregion
#region Manged SSPI
/*
* The managed SSPI implementation from the new TLS code.
*/
internal abstract bool SupportsTlsContext {
get;
}
internal abstract IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, TlsProtocols protocolFlags,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
MonoTlsSettings settings);
ref MonoSslPolicyErrors errors, ref int status11);
#endregion
}
}
@@ -39,7 +39,37 @@ namespace Mono.Security.Interface
public static partial class MonoTlsProviderFactory
{
/*
* Returns the currently installed @MonoTlsProvider, falling back to the default one.
* TLS Provider Initialization
* ===========================
*
* The "global" TLS Provider (returned by GetProvider()) may only be modified at
* application startup (before any of the TLS / Certificate code has been used).
*
* On mobile, the default provider is specified at compile time using a property
* in the .csproj file (which can be set from the IDE). When using the linker, all
* other providers will be linked-out, so you won't be able to choose a different
* provider at run-time.
*
* On desktop, the default provider can be specified with the MONO_TLS_PROVIDER
* environment variable. The following options are currently supported:
*
* "default" - let Mono pick the best one for you (recommended)
* "old" or "legacy" - Mono's old managed TLS implementation
* "appletls" (currently XamMac only, set via .csproj property)
* "btls" - the new boringssl based provider (coming soon).
*
* On all platforms (except mobile with linker), you can call
*
* MonoTlsProviderFactory.Initialize(string)
*
* to use a different provider.
*
*/
#region Provider Initialization
/*
* Returns the global @MonoTlsProvider, initializing the TLS Subsystem if necessary.
*
* This method throws @NotSupportedException if no TLS Provider can be found.
*/
@@ -49,42 +79,64 @@ namespace Mono.Security.Interface
}
/*
* Returns the default @MonoTlsProvider.
*
* This method throws @NotSupportedException if no TLS Provider can be found.
* Check whether the TLS Subsystem is initialized.
*/
public static MonoTlsProvider GetDefaultProvider ()
{
return (MonoTlsProvider)NoReflectionHelper.GetDefaultProvider ();
}
/*
* GetProvider() attempts to load and install the default provider and throws on error.
*
* This property checks whether a provider has previously been installed by a call
* to either GetProvider() or InstallProvider().
*
*/
public static bool HasProvider {
public static bool IsInitialized {
get {
return NoReflectionHelper.HasProvider;
return NoReflectionHelper.IsInitialized;
}
}
/*
* Selects the default TLS Provider.
*
* May only be called at application startup and will throw
* @InvalidOperationException if a provider has already been installed.
* Initialize the TLS Subsystem.
*
* This method may be called at any time. It ensures that the TLS Subsystem is
* initialized and a provider available.
*/
public static void SetDefaultProvider (string name)
public static void Initialize ()
{
NoReflectionHelper.SetDefaultProvider (name);
NoReflectionHelper.Initialize ();
}
public static MonoTlsProvider GetProvider (string name)
/*
* Initialize the TLS Subsystem with a specific provider.
*
* May only be called at application startup (before any of the TLS / Certificate
* APIs have been used).
*
* Throws @NotSupportedException if the TLS Subsystem is already initialized
* (@IsInitialized returns true) or the requested provider is not supported.
*
* On mobile, this will always throw @NotSupportedException when using the linker.
*/
public static void Initialize (string provider)
{
return (MonoTlsProvider)NoReflectionHelper.GetProvider (name);
NoReflectionHelper.Initialize (provider);
}
/*
* Checks whether @provider is supported.
*
* On mobile, this will always return false when using the linker.
*/
public static bool IsProviderSupported (string provider)
{
return NoReflectionHelper.IsProviderSupported (provider);
}
#endregion
#region Call-by-call selection
/*
* Returns the requested TLS Provider, for use with the call-by-call APIs below.
*
* Throw @NotSupportedException if the requested provider is not supported or
* when using the linker on mobile.
*/
public static MonoTlsProvider GetProvider (string provider)
{
return (MonoTlsProvider)NoReflectionHelper.GetProvider (provider);
}
/*
@@ -108,6 +160,24 @@ namespace Mono.Security.Interface
{
return (IMonoSslStream)NoReflectionHelper.GetMonoSslStream (stream);
}
#endregion
#region Obsolete APIs
[Obsolete]
public static MonoTlsProvider GetDefaultProvider ()
{
return GetProvider ();
}
[Obsolete]
public static void SetDefaultProvider (string name)
{
Initialize (name);
}
#endregion
}
}
@@ -82,6 +82,7 @@ namespace Mono.Security.Interface
get; set;
}
[CLSCompliant (false)]
public CipherSuiteCode[] EnabledCiphers {
get; set;
}
@@ -38,6 +38,8 @@ using System.Security.Cryptography;
using Mono.Security.Cryptography;
using Mono.Security.X509.Extensions;
using SSCX = System.Security.Cryptography.X509Certificates;
namespace Mono.Security.X509 {
#if INSIDE_CORLIB
@@ -51,12 +53,14 @@ namespace Mono.Security.X509 {
private X509CertificateCollection _certificates;
private ArrayList _crls;
private bool _crl;
private bool _newFormat;
private string _name;
internal X509Store (string path, bool crl)
internal X509Store (string path, bool crl, bool newFormat)
{
_storePath = path;
_crl = crl;
_newFormat = newFormat;
}
// properties
@@ -126,6 +130,11 @@ namespace Mono.Security.X509 {
{
CheckStore (_storePath, true);
if (_newFormat) {
ImportNewFormat (certificate);
return;
}
string filename = Path.Combine (_storePath, GetUniqueName (certificate));
if (!File.Exists (filename)) {
filename = Path.Combine (_storePath, GetUniqueNameWithSerial (certificate));
@@ -165,6 +174,9 @@ namespace Mono.Security.X509 {
{
CheckStore (_storePath, true);
if (_newFormat)
throw new NotSupportedException ();
string filename = Path.Combine (_storePath, GetUniqueName (crl));
if (!File.Exists (filename)) {
using (FileStream fs = File.Create (filename)) {
@@ -177,6 +189,11 @@ namespace Mono.Security.X509 {
public void Remove (X509Certificate certificate)
{
if (_newFormat) {
RemoveNewFormat (certificate);
return;
}
string filename = Path.Combine (_storePath, GetUniqueNameWithSerial (certificate));
if (File.Exists (filename)) {
File.Delete (filename);
@@ -192,6 +209,9 @@ namespace Mono.Security.X509 {
public void Remove (X509Crl crl)
{
if (_newFormat)
throw new NotSupportedException ();
string filename = Path.Combine (_storePath, GetUniqueName (crl));
if (File.Exists (filename)) {
File.Delete (filename);
@@ -199,6 +219,41 @@ namespace Mono.Security.X509 {
}
}
// new format
void ImportNewFormat (X509Certificate certificate)
{
#if INSIDE_CORLIB
throw new NotSupportedException ();
#else
using (var sscxCert = new SSCX.X509Certificate (certificate.RawData)) {
var hash = SSCX.X509Helper2.GetSubjectNameHash (sscxCert);
var filename = Path.Combine (_storePath, string.Format ("{0:x8}.0", hash));
if (!File.Exists (filename)) {
using (FileStream fs = File.Create (filename))
SSCX.X509Helper2.ExportAsPEM (sscxCert, fs, true);
ClearCertificates ();
}
}
#endif
}
void RemoveNewFormat (X509Certificate certificate)
{
#if INSIDE_CORLIB
throw new NotSupportedException ();
#else
using (var sscxCert = new SSCX.X509Certificate (certificate.RawData)) {
var hash = SSCX.X509Helper2.GetSubjectNameHash (sscxCert);
var filename = Path.Combine (_storePath, string.Format ("{0:x8}.0", hash));
if (File.Exists (filename)) {
File.Delete (filename);
ClearCertificates ();
}
}
#endif
}
// private stuff
private string GetUniqueNameWithSerial (X509Certificate certificate)
@@ -45,8 +45,12 @@ namespace Mono.Security.X509 {
static private string _userPath;
static private string _localMachinePath;
static private string _newUserPath;
static private string _newLocalMachinePath;
static private X509Stores _userStore;
static private X509Stores _machineStore;
static private X509Stores _newUserStore;
static private X509Stores _newMachineStore;
private X509StoreManager ()
{
@@ -55,10 +59,10 @@ namespace Mono.Security.X509 {
internal static string CurrentUserPath {
get {
if (_userPath == null) {
_userPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
_userPath = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
".mono");
_userPath = Path.Combine(_userPath, "certs");
_userPath = Path.Combine (_userPath, "certs");
}
return _userPath;
}
@@ -76,10 +80,34 @@ namespace Mono.Security.X509 {
}
}
internal static string NewCurrentUserPath {
get {
if (_newUserPath == null) {
_newUserPath = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
".mono");
_newUserPath = Path.Combine (_newUserPath, "new-certs");
}
return _newUserPath;
}
}
internal static string NewLocalMachinePath {
get {
if (_newLocalMachinePath == null) {
_newLocalMachinePath = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData),
".mono");
_newLocalMachinePath = Path.Combine (_newLocalMachinePath, "new-certs");
}
return _newLocalMachinePath;
}
}
static public X509Stores CurrentUser {
get {
if (_userStore == null)
_userStore = new X509Stores(CurrentUserPath);
_userStore = new X509Stores (CurrentUserPath, false);
return _userStore;
}
@@ -88,12 +116,30 @@ namespace Mono.Security.X509 {
static public X509Stores LocalMachine {
get {
if (_machineStore == null)
_machineStore = new X509Stores (LocalMachinePath);
_machineStore = new X509Stores (LocalMachinePath, false);
return _machineStore;
}
}
static public X509Stores NewCurrentUser {
get {
if (_newUserStore == null)
_newUserStore = new X509Stores (NewCurrentUserPath, true);
return _newUserStore;
}
}
static public X509Stores NewLocalMachine {
get {
if (_newMachineStore == null)
_newMachineStore = new X509Stores (NewLocalMachinePath, true);
return _newMachineStore;
}
}
// Merged stores collections
// we need to look at both the user and the machine (entreprise)
// certificates/CRLs when building/validating a chain
@@ -44,15 +44,17 @@ namespace Mono.Security.X509 {
class X509Stores {
private string _storePath;
private bool _newFormat;
private X509Store _personal;
private X509Store _other;
private X509Store _intermediate;
private X509Store _trusted;
private X509Store _untrusted;
internal X509Stores (string path)
internal X509Stores (string path, bool newFormat)
{
_storePath = path;
_newFormat = newFormat;
}
// properties
@@ -61,7 +63,7 @@ namespace Mono.Security.X509 {
get {
if (_personal == null) {
string path = Path.Combine (_storePath, Names.Personal);
_personal = new X509Store (path, false);
_personal = new X509Store (path, false, false);
}
return _personal;
}
@@ -71,7 +73,7 @@ namespace Mono.Security.X509 {
get {
if (_other == null) {
string path = Path.Combine (_storePath, Names.OtherPeople);
_other = new X509Store (path, false);
_other = new X509Store (path, false, false);
}
return _other;
}
@@ -81,7 +83,7 @@ namespace Mono.Security.X509 {
get {
if (_intermediate == null) {
string path = Path.Combine (_storePath, Names.IntermediateCA);
_intermediate = new X509Store (path, true);
_intermediate = new X509Store (path, true, _newFormat);
}
return _intermediate;
}
@@ -91,7 +93,7 @@ namespace Mono.Security.X509 {
get {
if (_trusted == null) {
string path = Path.Combine (_storePath, Names.TrustedRoot);
_trusted = new X509Store (path, true);
_trusted = new X509Store (path, true, _newFormat);
}
return _trusted;
}
@@ -101,7 +103,7 @@ namespace Mono.Security.X509 {
get {
if (_untrusted == null) {
string path = Path.Combine (_storePath, Names.Untrusted);
_untrusted = new X509Store (path, false);
_untrusted = new X509Store (path, false, _newFormat);
}
return _untrusted;
}
@@ -138,7 +140,7 @@ namespace Mono.Security.X509 {
if (!create && !Directory.Exists (path))
return null;
return new X509Store (path, true);
return new X509Store (path, true, false);
}
// names
@@ -151,7 +153,7 @@ namespace Mono.Security.X509 {
public const string IntermediateCA = "CA";
public const string TrustedRoot = "Trust";
public const string Untrusted = "Disallowed";
public Names () {}
}
}
@@ -143,7 +143,6 @@
./Mono.Security.Interface/HashAlgorithmType.cs
./Mono.Security.Interface/IBufferOffsetSize.cs
./Mono.Security.Interface/IMonoTlsEventSink.cs
./Mono.Security.Interface/IMonoTlsContext.cs
./Mono.Security.Interface/IMonoSslStream.cs
./Mono.Security.Interface/MonoTlsConnectionInfo.cs
./Mono.Security.Interface/MonoTlsProvider.cs
@@ -30,10 +30,10 @@ using System;
namespace Microsoft.Win32.SafeHandles
{
public abstract class SafeNCryptHandle : System.Runtime.InteropServices.SafeHandle
public abstract class SafeNCryptHandle : SafeHandleZeroOrMinusOneIsInvalid
{
protected SafeNCryptHandle ()
: base (IntPtr.Zero, true)
: base (true)
{
}
@@ -70,13 +70,15 @@ namespace System.IO.Pipes
}
#endif
#if !MOBILE
public AnonymousPipeServerStream (PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity)
: base (direction, bufferSize)
{
if (direction == PipeDirection.InOut)
throw new NotSupportedException ("Anonymous pipe direction can only be either in or out.");
#if MOBILE
throw new NotImplementedException ();
#else
if (IsWindows)
impl = new Win32AnonymousPipeServer (this, direction, inheritability, bufferSize, pipeSecurity);
else
@@ -84,8 +86,8 @@ namespace System.IO.Pipes
InitializeHandle (impl.Handle, false, false);
IsConnected = true;
}
#endif
}
[MonoTODO]
public AnonymousPipeServerStream (PipeDirection direction, SafePipeHandle serverSafePipeHandle, SafePipeHandle clientSafePipeHandle)
@@ -100,21 +100,23 @@ namespace System.IO.Pipes
#endif
}
#if !MOBILE
public NamedPipeClientStream (string serverName, string pipeName, PipeAccessRights desiredAccessRights, PipeOptions options, TokenImpersonationLevel impersonationLevel, HandleInheritability inheritability)
: base (ToDirection (desiredAccessRights), DefaultBufferSize)
{
if (impersonationLevel != TokenImpersonationLevel.None ||
inheritability != HandleInheritability.None)
throw ThrowACLException ();
#if MOBILE
throw new NotImplementedException ();
#else
if (IsWindows)
impl = new Win32NamedPipeClient (this, serverName, pipeName, desiredAccessRights, options, inheritability);
else
impl = new UnixNamedPipeClient (this, serverName, pipeName, desiredAccessRights, options, inheritability);
}
#endif
}
~NamedPipeClientStream () {
Dispose (false);
}
@@ -163,6 +165,10 @@ namespace System.IO.Pipes
throw new NotImplementedException ();
}
protected override internal void CheckPipePropertyOperations () {
base.CheckPipePropertyOperations();
}
public int NumberOfServerInstances {
get {
CheckPipePropertyOperations ();
@@ -83,7 +83,6 @@ namespace System.IO.Pipes
}
#endif
#if !MOBILE
public NamedPipeServerStream (string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize, PipeSecurity pipeSecurity)
: this (pipeName, direction, maxNumberOfServerInstances, transmissionMode, options, inBufferSize, outBufferSize, pipeSecurity, HandleInheritability.None)
{
@@ -100,7 +99,9 @@ namespace System.IO.Pipes
{
var rights = ToAccessRights (direction) | additionalAccessRights;
// FIXME: reject some rights declarations (for ACL).
#if MOBILE
throw new NotImplementedException ();
#else
if (IsWindows)
impl = new Win32NamedPipeServer (this, pipeName, maxNumberOfServerInstances, transmissionMode,
rights, options, inBufferSize, outBufferSize,
@@ -110,8 +111,8 @@ namespace System.IO.Pipes
rights, options, inBufferSize, outBufferSize, inheritability);
InitializeHandle (impl.Handle, false, (options & PipeOptions.Asynchronous) != PipeOptions.None);
}
#endif
}
public NamedPipeServerStream (PipeDirection direction, bool isAsync, bool isConnected, SafePipeHandle safePipeHandle)
: base (direction, DefaultBufferSize)
@@ -140,14 +141,12 @@ namespace System.IO.Pipes
impl.Disconnect ();
}
#if !MOBILE
[MonoTODO]
[SecurityPermission (SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)]
public void RunAsClient (PipeStreamImpersonationWorker impersonationWorker)
{
throw new NotImplementedException ();
}
#endif
public void WaitForConnection ()
{
@@ -173,7 +172,6 @@ namespace System.IO.Pipes
throw new NotImplementedException ();
}
#if !MOBILE
// async operations
Action wait_connect_delegate;
@@ -190,7 +188,6 @@ namespace System.IO.Pipes
{
wait_connect_delegate.EndInvoke (asyncResult);
}
#endif
}
}
Loaded 100 of 618 files, more files were not shown because too many files have changed in this diff. Show more