Friday 26 April 2024

Ubuntu RDP (XRD)

 RDP (Remote Desktop Protocol) to connect to an Ubuntu system. However, by default, Ubuntu does not come with a built-in RDP server like Windows. You would need to install and configure an RDP server on your Ubuntu machine.

One popular option for this is xrdp, which is an open-source remote desktop solution for Linux. You can install xrdp on Ubuntu using the following steps:

  1. Open a terminal on your Ubuntu system.
  2. Update the package index:
sql
sudo apt update
  1. Install xrdp:
sudo apt install xrdp
  1. Once xrdp is installed, it should start automatically. You can check its status with:
lua
sudo systemctl status xrdp
  1. By default, xrdp listens on port 3389. You may need to open this port on your firewall if it's not already open.

  2. Now, you can use an RDP client on another machine to connect to your Ubuntu system using its IP address or hostname.

Keep in mind that while xrdp provides RDP functionality, the user experience may differ from using RDP on a Windows system. Additionally, y

GO LANG channel, channel cache

 In Go, a channel is a powerful construct used for communication and synchronization between goroutines (concurrently executing functions). It provides a way for goroutines to send data to and receive data from each other, allowing them to communicate without sharing memory, which helps prevent race conditions and ensures safe concurrent access to shared resources.

A channel is a typed conduit through which you can send and receive values with the channel operator, <-. The data sent and received via channels must be of the same type. Channels can be created using the make function with the chan keyword.

Here's a basic example of creating and using a channel in Go:

import "fmt" func main() { // Create a channel of integers ch := make(chan int) // Start a goroutine that sends values to the channel go func() { ch <- 1 // Send 1 to the channel ch <- 2 // Send 2 to the channel ch <- 3 // Send 3 to the channel close(ch) // Close the channel when done sending values }() // Receive values from the channel for value := range ch { fmt.Println("Received:", value) } }

In this example:


  • We create a channel of integers with make(chan int).
  • We start a goroutine (concurrently executing function) that sends three integer values to the channel (1, 2, 3), and then closes the channel using close(ch) to indicate that no more values will be sent.
  • In the main goroutine, we use a for loop with the range keyword to receive values from the channel until it is closed. The loop iterates over the values sent to the channel and prints them.

Channels provide a powerful way to coordinate the execution of concurrent operations in Go, enabling safe communication between goroutines. They are a fundamental feature of Go's concurrency model and are widely used in concurrent programming in Go.



Channel cache:


n Go, channels themselves do not have built-in caching mechanisms. However, the behavior of a channel can resemble caching under certain circumstances.

When a sender sends a value on a channel, it will block until there is a receiver ready to receive that value. If there is no receiver ready at the time of sending, the sender will block until a receiver is ready. This behavior effectively buffers the sent value until it's received.

Consider this example:

package main import ( "fmt" ) func main() { ch := make(chan int, 2) // Buffered channel with capacity 2 // Sender goroutine go func() { ch <- 1 fmt.Println("Sent: 1") ch <- 2 fmt.Println("Sent: 2") ch <- 3 // This will block until there's a receiver ready fmt.Println("Sent: 3") }() // Receiver goroutine go func() { fmt.Println("Received:", <-ch) }() // Ensure main goroutine doesn't exit prematurely select {} }

In this example, we've created a buffered channel with a capacity of 2 (make(chan int, 2)). This means the channel can hold up to two values without blocking the sender. When the sender sends two values (1 and 2), it won't block because there is space available in the channel's buffer.

However, when the sender attempts to send a third value (3), it will block because the channel's buffer is full and there's no receiver ready to receive a value.

So, while channels don't have caching mechanisms in the traditional sense, buffered channels can hold a certain number of values before the sender blocks, which can resemble a form of caching behavior.

ubuntu install file/pkgm, list files

install

 wget <url>

sudo dpkg -i filename.deb



list files



find / -type f


find   find

-type f - find files 

/ root directory can be my ./dir

ubuntu show list of running process

ps aux | grep '<myName>' 

GO LANG FIPS

 GO LANG FIPS :

BORING - CRYPOT : FIPS cert

https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/4407

https://boringssl.googlesource.com/boringssl/+/master/crypto/fipsmodule/FIPS.md


Documentation Explanation :

https://medium.com/cyberark-engineering/navigating-fips-compliance-for-go-applications-libraries-integration-and-security-42ac87eec40b



FIPS only module :


https://github.com/golang/go/blob/go1.19.3/src/crypto/tls/fipsonly/fipsonly.go


add code :

in package main :

import _ "crypto/tls/fipsonly"

Document, how to look for FIPS :

https://kupczynski.info/posts/fips-golang/


// CGO enabled is to enable running c * must have thi s

Build 

GOEXPERIMENT=boringcrypto CGO_ENABLED=1 go build


// verify :

https://stackoverflow.com/questions/75638176/how-can-i-check-whether-my-golang-app-uses-boringcrypto-instead-of-the-native-go

https://kupczynski.info/posts/fips-golang/


nm - name list


go tool nm main  | grep -E 'sig.FIPSOnly|sig.BoringCrypto|sig.StandardCrypto'



 go tool nm file-server | grep -i boring/sig

Tuesday 23 April 2024

Self signed certificate for Postman, curl, snow validation

 Postman, curl, snow validation :


curl flag -k (insecure to ingore)


postman: settings -> SSL certification verification


SNOW cant turn off,


to ensure self signed certificate, ensure server certificate has subjectAlternativeName: host:"<IPADDR>" can match server IP

Then ensure curl has 

-cacert fCA.crt for curl

curl --verbose can give detail handshake info

and postman -> settings -> certificate -> CA certificate 


-----------------------------------------------

SNOW will validate server certifiate, subjectAltnerativeName, then rootCA(Java)


SNOW -  no longer need server certificate to be prestored in certificates<if failed, upload>, however, need to store CA(if not known CA)'s cert in system





Monday 22 April 2024

service certiificates

 service 

com.glide.communications.httpclient.verify_hostname -> true

com.glide.communications.trustmanager_trust_all -> true



should be true at all time they dont work even set to false



add your self signed certs

RootCA to servicenow certificates

if not working also add server certs(self signed)


it will work.

For key-store genereated based certificates, use pk12 is good enough. geenrate jks forcefully will have issues