I am using mono develop on Ubuntu os.I downloaded Tweetinvi lib from nuget.This used to work on windows.
public static void Main (string[] args)
{
var appCredentials = new TwitterCredentials("AppCred", "AppCred");
var authenticationContext = AuthFlow.InitAuthentication(appCredentials);
Process.Start(authenticationContext.AuthorizationURL);
string pinCode = Console.ReadLine();
var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pinCode, authenticationContext);
Auth.SetCredentials(userCredentials);
var firstTweet = Tweet.PublishTweet("Hello World!");
}
Now I get this exception : Unhandled Exception:
System.TypeLoadException: Could not resolve type with token 01000015, in terminal.
I tried different versions of the Tweetinvi library and I got: System.TypeInitialization Exception,at
var authenticationContext = AuthFlow.InitAuthentication(appCredentials);
This worked well in Xamarin Studio in Windows but I must do this in Linux.I guess I must add a reference or something so that ubuntu can open firefox and start authentication process.
Related
I have the following code in my Program.cs file in a console app that is hosted in AKS.
private IConfigurationRoot _configurationRoot;
private IConfigurationRoot ConfigurationRoot
{
get
{
if (_configurationRoot == null)
{
var deployedEnv = System.Environment.GetEnvironmentVariable("DeploymentEnv");
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile($"appsettings.{deployedEnv}.json", true);
_configurationRoot = builder.Build();
#if DEBUG
_configurationRoot = builder.AddAzureKeyVault(_configurationRoot["AzureKeyVaultURL"]).Build();
#else
_configurationRoot = builder.AddAzureKeyVault(_configurationRoot["AzureKeyVaultURL"], _configurationRoot["AzureKeyVaultClientId"], _configurationRoot["AzureKeyVaultClientSecret"]).Build();
#endif
}
return _configurationRoot;
}
}
I am getting the following error regarding the client secret and I am not sure why. I am following a similar implementation in our web services without issue. Any idea what the root cause is? I have been through many console app configuration posts/tutorials but have not found an answer. Thank you!
System.ArgumentNullException: Value cannot be null.
Parameter name: clientSecret
at Microsoft.Extensions.Configuration.AzureKeyVaultConfigurationExtensions.AddAzureKeyVault(IConfigurationBuilder configurationBuilder, String vault, String clientId, String clientSecret, IKeyVaultSecretManager manager)
at GlobalCustomerIdUpdater.Updaters.GlobalCustomerIdUpdater.get_ConfigurationRoot() in /src/GlobalCustomerIdUpdater/Updaters/GlobalCustomerIdUpdateCoordinator.cs:line 37
at GlobalCustomerIdUpdater.Updaters.GlobalCustomerIdUpdater.get_AppointmentDatabaseConnectionFactory() in /src/GlobalCustomerIdUpdater/Updaters/GlobalCustomerIdUpdateCoordinator.cs:line 66
at GlobalCustomerIdUpdater.Updaters.GlobalCustomerIdUpdater.Update() in /src/GlobalCustomerIdUpdater/Updaters/GlobalCustomerIdUpdateCoordinator.cs:line 95
Based on your code:
#if DEBUG
_configurationRoot = builder.AddAzureKeyVault(_configurationRoot["AzureKeyVaultURL"]).Build();
#else
_configurationRoot = builder.AddAzureKeyVault(_configurationRoot["AzureKeyVaultURL"], _configurationRoot["AzureKeyVaultClientId"], _configurationRoot["AzureKeyVaultClientSecret"]).Build();
#endif
In DEBUG mode, only AzureKeyVaultURL is set in configuration, that might be the root cause of your issue.
By the way, the stack trace shows that the error occurs in GlobalCustomerIdUpdater. Could you please provide more codes about it?
We need to implement checks of client certificate validity in our ASP.NET Core 2.X application that is dockerized and run under Linux. In particular, we are interested in revocation status of certificates. Such validation was implemented by using X509Chain and it works as expected.
var chain = new X509Chain();
var chainPolicy = new X509ChainPolicy
{
RevocationMode = X509RevocationMode.Online,
RevocationFlag = X509RevocationFlag.EntireChain
};
chain.ChainPolicy = chainPolicy;
...
Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
....
However, we have requirements regarding the expiration time of CRL cache for our application. It looks like Linux (I assume it is debian for mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim image) caches CRLs by default - first request last for ~150ms and the following requests are handled almost in no time (unfortunately I cannot find available information to confirm this observation).
What is default time for CRL cache in Linux (debian)? Is it possible to change it? Is there a way to check list of the cached CRL?
Is possible to clean CRL cache like in Windows?
certutil -urlcache * delete
Linux certificate util dirmngr seems to be is not a part of the mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim base image for ASP.NET Core 2.2 applications.
As it is .net Core, which is open source, have you looked up the sources at github. There you'lkl find a call to the CrlCache which shows where data is stored:
namespace Internal.Cryptography.Pal
{
internal static class CrlCache
{
private static readonly string s_crlDir =
PersistedFiles.GetUserFeatureDirectory(
X509Persistence.CryptographyFeatureName,
X509Persistence.CrlsSubFeatureName);
internal static class X509Persistence
{
internal const string CryptographyFeatureName = "cryptography";
internal const string X509StoresSubFeatureName = "x509stores";
internal const string CrlsSubFeatureName = "crls";
internal const string OcspSubFeatureName = "ocsp";
}
...
internal const string TopLevelDirectory = "dotnet";
internal const string TopLevelHiddenDirectory = "." + TopLevelDirectory;
internal const string SecondLevelDirectory = "corefx";
...
internal static string GetUserFeatureDirectory(params string[] featurePathParts)
{
Debug.Assert(featurePathParts != null);
Debug.Assert(featurePathParts.Length > 0);
if (s_userProductDirectory == null)
{
EnsureUserDirectories();
}
return Path.Combine(s_userProductDirectory, Path.Combine(featurePathParts));
}
private static void EnsureUserDirectories()
{
string userHomeDirectory = GetHomeDirectory();
if (string.IsNullOrEmpty(userHomeDirectory))
{
throw new InvalidOperationException(SR.PersistedFiles_NoHomeDirectory);
}
s_userProductDirectory = Path.Combine(
userHomeDirectory,
TopLevelHiddenDirectory,
SecondLevelDirectory);
}
internal static string GetHomeDirectory()
{
// First try to get the user's home directory from the HOME environment variable.
// This should work in most cases.
string userHomeDirectory = Environment.GetEnvironmentVariable("HOME");
So the path should be $HOME/.dotnet/corefx/cryptography/crls
Whatever I tried I cannot set an extension property on a User object, here is a reproducible piece of code:
public async Task CleanTest(string extName)
{
ExtensionProperty ep = new ExtensionProperty
{
Name = extName,
DataType = "String",
TargetObjects = { "User" }
};
App app = (App)(await _client.Applications.Where(a => a.AppId == _managementAppClientId).ExecuteSingleAsync());
app.ExtensionProperties.Add(ep);
await app.UpdateAsync();
GraphUser user = (GraphUser)(await _client.Users.Where(u => u.UserPrincipalName.Equals("email")).ExecuteSingleAsync());
string propName = FormatExtensionPropertyName(extName); //formats properly as extesion_xxx_name
user.SetExtendedProperty(propName, "testvalue");
//user.SetExtendedProperty(extName, "testvalue");
await user.UpdateAsync(); // fails here
}
user.UpdateAsync() according to Fiddler doesn't even go out and application fails with an exception:
"The property 'extension_e206e28ff36244b19bc56c01160b9cf0_UserEEEqdbtgd3ixx2' does not exist on type 'Microsoft.Azure.ActiveDirectory.GraphClient.Internal.User'. Make sure to only use property names that are defined by the type."
This issue is also being tracked here:
https://github.com/Azure-Samples/active-directory-dotnet-graphapi-console/issues/28
I've got an alternative workaround for this bug, for those that want to use the version 5.7 OData libraries rather than redirecting to the v5.6.4 versions.
Add a request pipeline configuration handler.
// initialize in the usual way
ActiveDirectoryClient activeDirectoryClient =
AuthenticationHelper.GetActiveDirectoryClientAsApplication();
// after initialization add a handler to the request pipline configuration.
activeDirectoryClient.Context
.Configurations.RequestPipeline
.OnMessageWriterSettingsCreated(UndeclaredPropertyHandler);
In the handler, change the ODataUndeclaredPropertyBehaviorKinds value on the writer settings to SupportUndeclaredValueProperty.
private static void UndeclaredPropertyHandler(MessageWriterSettingsArgs args)
{
var field = args.Settings.GetType().GetField("settings",
BindingFlags.NonPublic | BindingFlags.Instance);
var settingsObject = field?.GetValue(args.Settings);
var settings = settingsObject as ODataMessageWriterSettings;
if (settings != null)
{
settings.UndeclaredPropertyBehaviorKinds =
ODataUndeclaredPropertyBehaviorKinds.SupportUndeclaredValueProperty;
}
}
Just in case you still looking for solution to this problem or someone else is facing the same issue:
I got similar issue and it looks like, at least for me, the problem was in latest version of "Microsoft.Data.Services.Client" package - 5.7.0 (or in one of it dependencies). When I downgraded to previous version - 5.6.4 it worked as a charm.
I had same symptoms - updating of extended property was failing even w/o any request is made (also used Fiddler)
Hope it helps!
Artem Liman
My app just got reject from apple and i believe it might be caused by them changing to test with ios 8.1. However I cannot reproduce the error in any way. Their chrash report states the app chrashes on startup.
It seems that the exception(have the crash log) comes from
<Warning> Unhandled managed exception: Access to the path "/var/mobile/Documents/settings" is denied. (System.UnauthorizedAccessException)
which originates from
Cirrious.MvvmCross.Plugins.File.MvxFileStore.WriteFileCommon
I am using the mvvmcross 3.11 MvxFileStore plugin. Deployment target ios7, 8.1 ios sdk.
I have been surfing the web and some states Documents directory has moved in iOS 8 and this might cause the exception.
But I cant wrap my head around the fact that I cant reproduce this error.
Do anyone have a similar issue, a suggestion how to fix or an idea how to reproduce their crash.
Anything is appreciated.
Update:
From the post it is suggested to do the following fix
int SystemVersion = Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]);
if (SystemVersion >= 8)
{
var documents = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].Path;
filename = Path.Combine(documents, sFile);
}
else
{
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // iOS 7 and earlier
filename = Path.Combine(documents, sFile);
}
I have tried adding it to our project. We used the MvxFileStore to create the path to the settings file
var filestore = Mvx.Resolve<IMvxFileStore>();
string path = filestore.PathCombine(filestore.NativePath (string.Empty), FILENAME);
Now We de the following
var filestore = Mvx.Resolve<IMvxFileStore>();
string path = this.DocsDir() + "/" + FILENAME;
public string DocsDir ()
{
var version = int.Parse(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]);
string docsDir = "";
if (version>=8) {
var docs = NSFileManager.DefaultManager.GetUrls (NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User) [0];
docsDir = docs.Path;
Console.WriteLine("ios 8++ "+docsDir);
} else {
docsDir = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
Console.WriteLine("ios 7.1-- " + docsDir);
}
return docsDir;
}
I will resubmit our app and post the result.
Okay,
The fix we did by seperating ios 8 and the rest of ios and do different implementations depending on the ios worked.
Apple has approved our apps and all is love (y)
I'm creating unit tests for our application, and I'm stuck. For testing I have a simple HelloWebServlet that I'm protecting via annotations:
#WebServlet(urlPatterns = {"/hello"})
#ServletSecurity(#HttpConstraint(rolesAllowed = {"user"}))
I'm starting the server the way that's always worked OK (see [1]) and creating users (see [2]) seems to be OK because output from CommandRunner calls to list-file-users and list-file-groups are correct, but I'm getting this error when I try to connect using the username and password:
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Unable to locate a login configuration
The calling code uses the Jersey client API:
#Test
public void testPingServletLoggedIn() {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter(GlassFishServerHelper.USERNAME, "xx"));
WebResource webResource = client.resource(GlassFishServerHelper.getBaseUri() + "/hello");
ClientResponse clientResponse = webResource
.accept(MediaType.TEXT_PLAIN)
.get(ClientResponse.class); // #GET
assertEquals(ClientResponse.Status.OK, clientResponse.getClientResponseStatus());
}
(Note: I tried to set javax.enterprise.system.core.security.level=FINE but that call failed with: PlainTextActionReporterFAILURENo configuration found for javax.enterprise.system.core.security . Drat!)
I've tried this against both glassfish-embedded-all-3.1.2.jar (our production version) and glassfish-embedded-all-3.2-b06.jar with the same results. What do you think would solve this? I've struggled and succeeded way too many times with GFE to give up without a fight!
==== [1] server startup (excerpt) ====
public static void startServer() {
GlassFishProperties gfProps = new GlassFishProperties();
gfProps.setPort("http-listener", PORT);
GLASSFISH = GlassFishRuntime.bootstrap().newGlassFish(gfProps);
GLASSFISH.start();
enableDefaultPrincipleToRoleMapping();
createUsersAndGroups();
ScatteredArchive archive = new ScatteredArchive(WEB_APP_NAME, ScatteredArchive.Type.WAR);
File classesDir = new File("out/production/simple-security-servlet-test");
archive.addClassPath(classesDir);
DEPLOYER = GLASSFISH.getDeployer();
APP_NAME = DEPLOYER.deploy(archive.toURI());
private static void enableDefaultPrincipleToRoleMapping() throws GlassFishException {
CommandRunner cr = GLASSFISH.getCommandRunner();
CommandResult result = cr.run("set",
"server-config.security-service.activate-default-principal-to-role-mapping=true");
}
==== [2] user creation (excerpt) ====
private static void createUsersAndGroups() throws GlassFishException {
CommandRunner commandRunner = GLASSFISH.getCommandRunner();
File passwordFile = new File("password-file.txt");
CommandResult result = commandRunner.run("create-file-user",
"--passwordfile", passwordFile.getAbsolutePath(),
"--groups", "user",
USERNAME
);
}
I was getting the same error and have managed to work around it, although my situation is slightly different. I'm starting GF 3.1.2 from the "maven-embedded-glassfish-plugin" maven plugin, but this might work for you as well.
Try setting the following system property:
java.security.auth.login.config=target/test-classes/login.conf
This should point to a copy of the login.conf file. You can find this file in the "config" folder in any Glassfish domain folder.