trying sign a file using gpg on Ubuntu 18.04 with following :
gpg --version
gpg (GnuPG) 2.2.4
libgcrypt 1.8.1
started the gpg-agent with following
gpg-agent --daemon --debug-level 9 --pinentry-program /usr/bin/pinentry-curses
exported the agent info by
export GPG_AGENT_INFO="~/.gnupg/S.gpg-agent:$(pgrep gpg-agent):1"
and TTY info by
export GPG_TTY=$(tty)
But when tried to sign a file using following command
gpg --output example.gpg --sign example.txt
The output is as follows
gpg-agent[11793]: DBG: chan_9 -> OK Pleased to meet you, process 25152
gpg-agent[11793]: DBG: chan_9 <- RESET
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- OPTION ttyname=/dev/pts/2
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- OPTION ttytype=xterm
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- OPTION lc-ctype=C.UTF-8
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- OPTION lc-messages=C.UTF-8
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- GETINFO version
gpg-agent[11793]: DBG: chan_9 -> D 2.2.4
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- OPTION allow-pinentry-notify
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- OPTION agent-awareness=2.1.0
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- SCD SERIALNO openpgp
gpg-agent[11793]: new connection to SCdaemon established (reusing)
gpg-agent[11793]: DBG: chan_10 -> SERIALNO openpgp
gpg-agent[11793]: DBG: chan_10 <- ERR 100696144 No such device <SCD>
gpg-agent[11793]: DBG: chan_9 -> ERR 100696144 No such device <SCD>
gpg-agent[11793]: DBG: chan_9 <- HAVEKEY 33F0F39FF1A5FA2A5F94CCD25F41F7F298CB2D2B 2E1C10D851E9F71B68923622C741DF42F2FE6AA2
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- KEYINFO 33F0F39FF1A5FA2A5F94CCD25F41F7F298CB2D2B
gpg-agent[11793]: DBG: agent_get_cache '33F0F39FF1A5FA2A5F94CCD25F41F7F298CB2D2B' (mode 2) ...
gpg-agent[11793]: DBG: ... miss
gpg-agent[11793]: DBG: chan_9 -> S KEYINFO 33F0F39FF1A5FA2A5F94CCD25F41F7F298CB2D2B D - - - P - - -
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- RESET
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- SIGKEY 33F0F39FF1A5FA2A5F94CCD25F41F7F298CB2D2B
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- SETKEYDESC Please+enter+the+passphrase+to+unlock+the+OpenPGP+secret+key:%0A%22Example+<Example#Example.com>%22%0A2048-bit+RSA+key,+ID+EF00F70672017CCC,%0Acreated+2017-11-06.%0A
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- SETHASH 10 06F405A35FDACC3696FCF9ED5A1A221EF0881B63B9E1E4F7A63429940D64FC347D1BB756427CCB53B855DDF99D19C604B4292E7FE306246FC22ABB7F8690C399
gpg-agent[11793]: DBG: chan_9 -> OK
gpg-agent[11793]: DBG: chan_9 <- PKSIGN
gpg-agent[11793]: DBG: agent_get_cache '33F0F39FF1A5FA2A5F94CCD25F41F7F298CB2D2B' (mode 2) ...
gpg-agent[11793]: DBG: ... miss
gpg-agent[11793]: starting a new PIN Entry
gpg-agent[11793]: DBG: connection to PIN entry established
gpg-agent[11793]: DBG: chan_9 -> INQUIRE PINENTRY_LAUNCHED 25154 curses 1.1.0 /dev/pts/2 xterm -
gpg-agent[11793]: DBG: chan_9 <- END
gpg-agent[11793]: DBG: error calling pinentry: Permission denied <Pinentry>
gpg-agent[11793]: failed to unprotect the secret key: Permission denied
gpg-agent[11793]: failed to read the secret key
gpg-agent[11793]: command 'PKSIGN' failed: Permission denied <Pinentry>
gpg-agent[11793]: DBG: chan_9 -> ERR 83918849 Permission denied <Pinentry>
gpg: signing failed: Permission denied
gpg: signing failed: Permission denied
flectra#testforbld:~$ gpg-agent[11793]: DBG: chan_9 <- [eof]
gpg-agent[11793]: DBG: chan_10 -> RESTART
gpg-agent[11793]: DBG: chan_10 <- OK
Related
I am using asp.net core 3.0 with sql server, trying to create microservice using docker. However when I tried to run docker-compose I am getting
"An error occurred while migrating or seeding the database." error. I have entity-framework 3.1 migrations in code, when the new database container spins-up I believe it is trying to run migrations but may be database doesn't exist.
My Startup.cs
public void ConfigureServices(IServiceCollection services)
{
var server = Configuration["DBServer"] ?? "192.168.0.3";
var port = Configuration["DBPort"] ?? "1432";
var user = Configuration["DBUser"] ?? "SA";
var password = Configuration["DBPassword"] ?? "Passw0rd1!";
var database = Configuration["Database"] ?? "AFE-Sales";
services.AddDbContext<InsuranceContext>(options => options.UseSqlServer($"Server={server},{port};Initial Catalog={database};User ID = {user}; Password={password}"));
Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["src/WebUI/WebUI.csproj", "src/WebUI/"]
COPY ["src/Application/Application.csproj", "src/Application/"]
COPY ["src/Domain/Domain.csproj", "src/Domain/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "src/Infrastructure/"]
RUN dotnet restore "src/WebUI/WebUI.csproj"
COPY . .
WORKDIR "/src/src/WebUI"
RUN dotnet build "WebUI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "WebUI.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Insurance.WebUI.dll"]
Docker-compose
version: '3.4'
services:
ms-sql-server:
image: "mcr.microsoft.com/mssql/server:2017-latest-ubuntu"
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "Passw0rd1!"
MSSQL_PID: Express
ports:
- "5432:5432"
- "1433:1433"
webui:
image: ${DOCKER_REGISTRY-}webui
container_name: mortgage
build:
context: .
dockerfile: src/WebUI/Dockerfile
ports:
- 5000:80
environment:
DBServer: "192.168.0.3"
DBPort: "1432"
DBUser: "SA"
DBPassword: "Passw0rd1!"
Database: "mortgage"
depends_on:
- ms-sql-server
DBContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlServer("Server=192.168.0.3,1432;Database=AFE-Sales;User ID=SA;Password=Passw0rd1!");
}
base.OnConfiguring(optionsBuilder);
}
appsettings.json
{
"UseInMemoryDatabase": true,
"ConnectionStrings": {
"Default": "Server=192.168.0.3,1432;Database=mortgage;User ID=SA;Password=Passw0rd1!",
Error I am getting
"mortgage | fail: Insurance.WebUI.Program[0]
mortgage | An error occurred while migrating or seeding the database.
mortgage | Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)
mortgage | at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool, SqlAuthenticationProviderManager sqlAuthProviderManager)"*
Your service is not able to resolve the ip address provided in connection string for sql server inside of docker server while running the containers.
I would suggest you to follow the steps provided inline to connect your sql server with .net core application
compose asp.net core service with sql server via docker compose
I am trying to edit openssh package & add custom code to create socket and send some message.
in other part of openssh package i am able to do but not able to perform same task in openssh-7.8p1->kex.c->choose_kex & in packet.c where we return error from
Code :
{
int sock = 0;
sock = socket(AF_INET, SOCK_STREAM, 0);
if(sock < 0) {
debug("%s: Unable to create socket: %s",__func__, strerror(errno));
return;
}
close(sock);
}
above code return error with log : too many open files (error code:24)
is it not possible to create socket while ssh handshake in progress?
I'm trying to perform a datatask with URLSession, when I run it on iOS11 device (iPhone 5S) I get a console error:
2017-09-22 15:22:17.942015-0300 app[1355:283536] TIC TCP Conn Failed [3:0x1c417af40]: 1:61 Err(61)
2017-09-22 15:22:17.943698-0300 app[1355:283536] Task <A32F0275-75C3-4F64-AB92-2E37527AB813>.<0> HTTP load failed (error code: -1004 [1:61])
2017-09-22 15:22:17.945265-0300 app[1355:283676] NSURLConnection finished with error - code -1004
Running on Simulator it doesn't happen.
What's causing it or how to fix it?
Here's what I'm doing
#define kEcardURL #"https://example.com/mobile/services/ecard/"
- (void)doSomething {
//Params Configuration
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
[oauth.userData valueForKey:#"wsuserid"], #"token",
nil];
NSString *path = #"fotoCartao";
NSData* params = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%#%#", kEcardURL, path]];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setHTTPMethod:#"POST"];
[urlRequest setValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
[urlRequest setHTTPBody:params];
NSURLSessionDataTask *dataTask = [[self session] dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if ([data length] > 0 && error == nil) {
if ([httpResponse statusCode] == 200) {
//do stuff
}
}
}];
[dataTask resume];
}
}
- (NSURLSession *)session {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Session Configuration
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
// Initialize Session
_session = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];
});
return _session;
}
Make sure the url is supported by running the following commands:
curl -v https://example.com/mobile/services/ecard/
nscurl --verbose --ats-diagnostics https://example.com/mobile/services/ecard/
Verify that you are not using cyphers hashes and protocols that are no longer supported by apple.
IOS 11 no longer supports these:
Cyphers:
RC4
3DES-CBC
AES-CBC
Hashes:
MD5
SHA-1
Key Sizes:
<2048-bit RSA Pub Keys
Protocols:
http://
SSLv3
TLS 1.0
TLS 1.1
If they are not supported you can whitelist the domain by using
the NSAppTransportSecurity property in you application plist file.
[SOLVED] It was caused by the TLS version (1.1) on server side.
Adding an entry in NSAppTransportSecurity as Wayne said solved the problem.
Plist entry:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
I'm a nodejs developer and I generally use a structure for my apps which holds a configuration package/object that holds references to my often used libs and configuration options. Generally this configuration object holds my database connections as well and it's reachable trough my application.
I tried to build similar to this in go and failed horribly.
My plan was to build a public variable which holds a reference for my config struct. But when I try to call my Config.Database I get this panic:
2017/02/19 14:05:44 http: panic serving 127.0.0.1:53554: runtime error: invalid memory address or nil pointer dereference
goroutine 50 [running]:
net/http.(*conn).serve.func1(0xc42027c000)
/usr/local/go/src/net/http/server.go:1491 +0x12a
panic(0x9f45c0, 0xc42000c100)
/usr/local/go/src/runtime/panic.go:458 +0x243
main.SignUp(0xc4202780e0)
/home/attila/dev/gopath/src/github.com/attilasatan/helloiris/handlers.go:31 +0x258
github.com/kataras/iris.HandlerFunc.Serve(0xafaf00, 0xc4202780e0)
/home/attila/dev/gopath/src/github.com/kataras/iris/http.go:211 +0x30
github.com/kataras/iris.(*Context).Do(0xc4202780e0)
/home/attila/dev/gopath/src/github.com/kataras/iris/context.go:152 +0x4d
github.com/kataras/iris.(*serveMux).BuildHandler.func1(0xc4202780e0)
/home/attila/dev/gopath/src/github.com/kataras/iris/http.go:1059 +0x6ea
github.com/kataras/iris.(*Framework).Build.func1.1(0xd87e20, 0xc4202701a0, 0xc420284000)
/home/attila/dev/gopath/src/github.com/kataras/iris/iris.go:411 +0x72
net/http.HandlerFunc.ServeHTTP(0xc420235080, 0xd87e20, 0xc4202701a0, 0xc420284000)
/usr/local/go/src/net/http/server.go:1726 +0x44
net/http.serverHandler.ServeHTTP(0xc420089f80, 0xd87e20, 0xc4202701a0, 0xc420284000)
/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc42027c000, 0xd88820, 0xc42015c200)
/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2293 +0x44d
2017/02/19 14:05:44 http: panic serving 127.0.0.1:53560: runtime error: invalid memory address or nil pointer dereference
goroutine 51 [running]:
net/http.(*conn).serve.func1(0xc42027c180)
/usr/local/go/src/net/http/server.go:1491 +0x12a
panic(0x9f45c0, 0xc42000c100)
/usr/local/go/src/runtime/panic.go:458 +0x243
main.SignUp(0xc4202ac070)
/home/attila/dev/gopath/src/github.com/attilasatan/helloiris/handlers.go:31 +0x258
github.com/kataras/iris.HandlerFunc.Serve(0xafaf00, 0xc4202ac070)
/home/attila/dev/gopath/src/github.com/kataras/iris/http.go:211 +0x30
github.com/kataras/iris.(*Context).Do(0xc4202ac070)
/home/attila/dev/gopath/src/github.com/kataras/iris/context.go:152 +0x4d
github.com/kataras/iris.(*serveMux).BuildHandler.func1(0xc4202ac070)
/home/attila/dev/gopath/src/github.com/kataras/iris/http.go:1059 +0x6ea
github.com/kataras/iris.(*Framework).Build.func1.1(0xd87e20, 0xc4202a60d0, 0xc4202840f0)
/home/attila/dev/gopath/src/github.com/kataras/iris/iris.go:411 +0x72
net/http.HandlerFunc.ServeHTTP(0xc420235080, 0xd87e20, 0xc4202a60d0, 0xc4202840f0)
/usr/local/go/src/net/http/server.go:1726 +0x44
net/http.serverHandler.ServeHTTP(0xc420089f80, 0xd87e20, 0xc4202a60d0, 0xc4202840f0)
/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc42027c180, 0xd88820, 0xc42015c480)
/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
Here is my configure file. As you can see I'm using tideland/golib/redis for redis connection.
configure.go
package main
import (
"fmt"
"strconv"
"time"
"github.com/tideland/golib/redis"
)
/*Configuration is the main type of app configuration */
type Configuration struct {
Database *redis.Connection
}
/*Config is app configuration holder */
var Config *Configuration
/*Configure handles database connection */
func Configure() (*Configuration, error) {
db, err := redis.Open(redis.TcpConnection("127.0.0.1:6379", 30*time.Second))
if err != nil {
fmt.Printf("Database connection error")
return nil, err
}
conn, err := db.Connection()
n, _ := conn.DoInt("INCR", "IDIDID")
fmt.Printf(strconv.Itoa(n))
if err != nil {
fmt.Printf("Database connection error")
return nil, err
}
/*Config is the main configuration object*/
Config := &Configuration{conn}
return Config, err
}
And here is where I use Config.Database.
handlers.go
func SignUp(ctx *iris.Context) {
mail := ctx.FormValue("email")
password := ctx.FormValue("password")
passwordConfirm := ctx.FormValue("password-confirm")
if password != passwordConfirm {
ctx.RenderWithStatus(iris.StatusBadRequest, "400.html", ErrorPageData{"passwords dont match"})
} else {
user := User{mail, password, 0}
db := Config.Database
userID, err := db.DoInt("INCR", "HELLOIRIS:ID")
if err != nil {
ctx.RenderWithStatus(iris.StatusBadRequest, "400.html", ErrorPageData{"passwords dont match"})
} else {
user.ID = userID
fmt.Printf("SAVED")
ctx.Render("signup-success.html", nil)
}
ctx.JSON(200, user)
}
}
After this fail I changed Configure function like this:
configure.go
func Configure() (Config *Configuration, err error) {
if Config != nil {
return
}
}
and I changed the usage at handler
handlers.go
config, err := Configure()
if err != nil {
ctx.RenderWithStatus(iris.StatusBadRequest, "400.html", ErrorPageData{"try again later"})
return
}
user := User{mail, password, 0}
db := config.Database
... and everything start to work perfectly.
My problem is I simply don't understand why... Why did I get this panic when I use a public pointer and why didn't I get when I returned the same pointer from a function?
Config := &Configuration{conn}
This line creates a new local variable Config so the global Config is never set to anything. Drop the : to not create a new variable and use the global Config instead.
You're getting this problem because your Config global variable is not set or still hold nil value. as the error said :
runtime error: invalid memory address or nil pointer dereference
Make sure you called
func Configure() before the handler called in your main function
and as tkausl answer remove the : when you assign the conn redis to global variable to be like this in your configure.go file:
Config = &Configuration{conn}
Using httpuv package, Is there a way to restart server with given period?
Down there, I'm sharing my work as a possible answer.
Any further advice is welcome.
After some trial and error, here's a working code that restarts server every 5 seconds:
library(httpuv)
host <- '127.0.0.1'
port <- 8080
app <- list(
call = function(req) {
list(
status = 200L,
headers = list('Content-Type' = 'text/plain'),
body = 'Hello'
)
}
)
run <- function(host, port, app, period) {
sv <- startServer(host, port, app)
on.exit(stopServer(sv))
cat("Server started\n")
restart <- Sys.time() + period
while (TRUE) {
service()
Sys.sleep(0.001)
if (Sys.time() > restart) {
stopServer(sv)
sv <- startServer(host, port, app)
restart <- Sys.time() + period
cat("Server restarted\n")
}
}
}
run(host, port, app, 5)